Skip to content
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

Riak3.2.0 ,using Post-commit #1137

Open
baoxiangwei opened this issue Jun 15, 2023 · 0 comments
Open

Riak3.2.0 ,using Post-commit #1137

baoxiangwei opened this issue Jun 15, 2023 · 0 comments

Comments

@baoxiangwei
Copy link

This Riak version is 3.2.0, using Post-commit hook .

This is my erlang code:

-module(post_commit).
-export([post/1]).

post(Object) ->
Path="/home/firefly/riak_new/riak_3.20/riak/rel/riak/test.sh",

KeyName = riak_object:key(Object),
io:format("Key name: ~s~n", [KeyName]),

BucketName = riak_object:bucket(Object), 
io:format("Bucket name: ~p~n", [BucketName]),

Value = riak_object:get_value(Object),
io:format("Object value: ~p~n", [Value]),

Command= io_lib:format("sh ~s ~s ~s ~n", [Path, [KeyName], [BucketName]]),
io:format("Command value: ~s~n", [Command]),

Output = os:cmd(Command),
io:format("~s~n", [Output]). 

when I add some data into a bucket,
curl -XPUT http://localhost:8098/types/my_bucket_type/buckets/some-bucket/keys/babbbvv -H "Content-Type: application/json" -d '{"name": "John Smith", "age": 42, "email": "john.smith@example.caa1111odd9911m"}'

I can only get the key name "babbbvv " , but I can not get the bucket name "some-bucket".

But if i use "riak remote_console", enter the erlang shell , Input this code:

Bucket = <<"my_bucket">>,
Key = <<"my_key">>,
ContentType = <<"text/plain">>,
Data = <<"hello world">>,
Object = riak_object:new(Bucket, Key, Data, [{<<"content-type">>, ContentType}]),
post_commit:post(Object).

I can get not only this key name "my_key", but also the bucket name "my_bucket".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant