tpjg / goriakpbc

A golang riak client inspired by the Ruby riak-client from Basho and riakpbc from mrb
Other
127 stars 27 forks source link

Go, Riak 2, data types and ORM #99

Closed danqing closed 9 years ago

danqing commented 9 years ago

It is a bit unclear to me that what Riak/Go versions this library supports. It seems that it supports Go 1.0 and Riak 1.4? Is it a valid assumption that we can drop Go 1.0 support at sometime? (for the model_11.go file, for example)

I'm new to Riak, but I think there's some big changes in Riak 2. What's the support for it? I see that there are the rdatatype.go and related files, but I can't really figure out how they are used. In particular, when using the ORM, are data types used under the hood, or not at all?

I may be missing something here, but any pointers will be appreciated! Thanks :)

tpjg commented 9 years ago

Actually model_11.go is not supported by Go 1.0 and will not be compiled as a result of the compiler directive on the first line. While this library itself doesn't use specific Go >1.0 (with the exception of the model_11.go file), it does depend on the golang/protobuf library that requires at least Go 1.2.

The ORM part (model*.go) maps Go structs to JSON in ordinary Riak objects, not a data type.

Most of the Riak 2.0 features are supported, like the CRDTs, however SSL and authentication is not (yet) supported.

danqing commented 9 years ago

So iiuc, model.go is for Go 1.0 and model_11.go is for Go 1.1+? If the repo requires Go 1.2+, then shall we drop the model.go file and only use the model_11.go file?

And so in order to use data types, we have to go with robjects, not ORM. Is that correct?

I feel like some more docs (wiki, etc.) may be very helpful - also if they can talk about the limitations, etc. then we can see whether we can help where appropriate.

Thanks!

tpjg commented 9 years ago

Well, effectively indeed the repo requires Go 1.2+ because of protobuf. We can't drop model.go because that contains the bulk of the ORM code, the model_11.go just adds a single feature that was made possibly when Go 1.1 was introduced.

You cannot use the ORM for data types, but also not robjects. They have their own specific types (RDtCounter, RDtFlag, RDtMap, RDtRegister, RDtSet).

There is a Wiki, but indeed documentation on the data types is almost none, with the exception of the automatically generated pages at http://godoc.org/github.com/tpjg/goriakpbc.

danqing commented 9 years ago

Do you think it will be possible to somehow make orm/robjects work with the data types? Also just to make sure I understand it correctly, ORM is basically a wrapper around robjects that converts them into structs. Is that right?

Thanks!

tpjg commented 9 years ago

Yes, you're right. The simple ORM that is included now provides a clean, simple mapping of Go structs so they can be stored and linked to other objects/structs in Riak - nothing more, nothing less. It was created to behave similar to the (now deprecated) Ripple gem from Basho and made migrating Ruby projects to Go a bit easier. I think changing the ORM to use data types now will break existing code so that is not preferred.

Creating another / additional wrapper around data types is of course possible, however I don't think there is an easy 1-1 mapping between Go types and the data types. Please also read the rationale why Ripple was continued here http://basho.com/tag/ripple-client-apis .

PS note that this library will probably soon be taken over by Basho (see https://github.com/tpjg/goriakpbc/issues/98).

danqing commented 9 years ago

Thanks for the info! :)