-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add convenience methods for creating new maps, sets, and counters #4
base: master
Are you sure you want to change the base?
Conversation
The current implementation is definitely a little crude. I currently have something like this:
Maybe something like the following would be better?
|
@hopkinsth If you could write some tests which utilize your convenience functions I'll merge this in. Idiomatic method documentation would be nice too. Example:
|
I apologize for not responding sooner—lots going on this week. I was originally thinking something like this... mp, err := bucket.CrdtMap("my-key-here")
if err != nil {
switch err.(type) {
case riaken_core.WRONG_CRDT_TYPE:
fmt.Println("Key does not match requested type!")
//or something like that
default:
fmt.Println("some other error?")
}
}
innerMap, err := mp.Map("my-map-key")
if err != nil {
//more "key doesn't match type" or something like that
//also "map not found, maybe?"
//error on duplicate keys?
//return old map on duplicate keys? (ew.)
}
innerSet, err := mp.Set("my-set-key")
//etc. That adds a fair amount of complexity and, with it, probably decreases performance. I'll push up a test and doc comments for the three methods in this PR soon. They would be handy to have. |
I pushed up a test for these methods, which just checks that all nested maps, counters, and sets refer to the same
I'm fairly certain these errors and my change aren't related, but let me know if something looks weird. Not sure yet what the first set of errors are about. I'm running these tests locally with Riak 2.0.1. |
@hopkinsth Assuming your database is local run The 2i test won't pass unless your backend is set to The two 1.4 Search's are expected (for now). |
We use several nested maps inside our app, and it would be more convenient to pass around just the map itself to different functions instead of the map and the crdt struct pointer. This isn't a critical problem, but it's a little more convenient to have a NewMap, NewSet, and NewCounter function available on map structs.
The other options for implementing this include stuff like:
crdt
field on map structsCrdt
field on mapsBut both those options seem like they create a weird API, so this made most sense to me.