Hi Luke
I tried that and didn't work for a bucket with bucket type = maps. My
erlang code below does work for buckets without types.
But I think its because I didn't set the hook for the typed bucket
correctly.Could you check my curl below, please ?
I did this to set the hook
curl -X PUT localhost:8098/riak/types/maps -H 'Content-Type:
application/json' -d
'{"props":{"precommit":[{"mod":"myhooks","fun":"precommit_hook"}]}}'
That returns 204, but when I get the props ...
curl http://localhost:8098/types/maps/props
{
"props": {
"active": true,
"allow_mult": true,
"basic_quorum": false,
"big_vclock": 50,
"chash_keyfun": {
"fun": "chash_std_keyfun",
"mod": "riak_core_util"
},
"claimant": "[email protected]",
"datatype": "map",
"dvv_enabled": true,
"dw": "quorum",
"last_write_wins": false,
"linkfun": {
"fun": "mapreduce_linkfun",
"mod": "riak_kv_wm_link_walker"
},
"n_val": 3,
"notfound_ok": true,
"old_vclock": 86400,
"postcommit": [],
"pr": 0,
"precommit": [],
"pw": 0,
"r": "quorum",
"rw": "quorum",
"small_vclock": 50,
"w": "quorum",
"young_vclock": 20
}
}
The hook code is ...
precommit_hook(Object) ->
case riak_object:bucket(Object) of
{BucketType, Bucket} -> Bstr = binary_to_list(Bucket), Btstr =
binary_to_list(BucketType);
Bucket -> Bstr = binary_to_list(Bucket), Btstr = <<"">>
end,
K = riak_object:key(Object),
Kstr = binary_to_list(K),
lager:info("MyHook Bucket type ~s, bucket ~s, key ~s [Btstr, Bstr,
Kstr]),
Object.
On 18 November 2016 at 14:15, Luke Bakken <[email protected]> wrote:
> Mav -
>
> Please remember to use "Reply All" so that the riak-users list can
> learn from what you find out. Thanks.
>
> Thebucket = riak_object:bucket(Object),
>
> Can you check to see if "Thebucket" is really a two-tuple of
> "{BucketType, Bucket}"? I believe that is what is returned.
>
> --
> Luke Bakken
> Engineer
> [email protected]
>
> On Fri, Nov 18, 2016 at 10:54 AM, Mav erick <[email protected]> wrote:
> > I have some initializing to do - like connecting to a notification
> server,
> > before I can use the commit hook. But I think I have figured that out now
> > that I learnt about supervisors and OTP
> >
> > I have one other question though ...
> > How do I get the bucket type of the bucket of the key that was committed
> ?
> >
> > I am using these to get the key and bucket names. But I cant seem to
> find a
> > call to get the bucket's bucket type
> >
> > Thebucket = riak_object:bucket(Object),
> > Thekey = riak_object:key(Object),
> >
> > Thanks !
> >
> > On 18 November 2016 at 12:14, Luke Bakken <[email protected]> wrote:
> >>
> >> Mav -
> >>
> >> Can you go into more detail? The subject of your message is
> >> "initializing a commit hook".
> >>
> >> --
> >> Luke Bakken
> >> Engineer
> >> [email protected]
> >>
> >> On Thu, Nov 17, 2016 at 9:09 AM, Mav erick <[email protected]> wrote:
> >> > Folks
> >> >
> >> > Is there way RIAK can call an erlang function in a module when RIAK
> >> > starts
> >> > up ?
> >> >
> >> > Thanks
> >> > Mav
> >
> >
>
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com