Build a Riak bucket over cURL

I would like to be able to create Riak branches over cURL. I searched online and could not find a way to do this. I know there are ways to do this easily with drivers, but you need to be able to do this with cURL for the Saas application I'm working on.

+4
source share
3 answers

One more thing - it is important to remember that there is no way to "create" a box explicitly, with a call (via CURL or the api client).

You can only create your own buckets using the call above.

The reason for this is - buckets - it's just a prefix for keys. Riak does not have an object that tracks buckets. There is no file, no variable in memory, or something like that. That's why simple list buckets are so expensive: Riak literally has to go through each key in the cluster and build a list of buckets by looking at the key prefixes.

The only thing that exists as real objects is buckets with non-default settings, i.e. custom buckets. Something that makes this curl command higher is that it tracks some non-standard settings for Riak to consult when a call comes into this bucket.

In any case, the moral of this story: you do not need to create buckets in the course of normal work. You can start writing for them, and they will appear (again, in the sense, keys with century-old prefixes will appear, which means that now they can be repeated on expensive calls to the "list of buckets").

You only need to issue a call for custom buckets (and you also do not want to do this too much, since there is a practical limit to the number of custom buckets created in a cluster, somewhere around 9000).

+3
source

You must execute PUT by passing the bucket properties you want as a json object, e.g.

curl -v http://riak3.local:8098/riak/newBucket -X PUT -H Content-Type:application/json --data-binary '{"props":{"n_val":5}}' 

docs contains more details.

+6
source

I also found that if you add a new object to a non-existing bucket, it will create this bucket on the fly.

Remember that buckets are automatically created when keys are added to them. There is no need to explicitly β€œcreate” a bucket (more on buckets and their properties further down the page).

Bucket Properties and Operations

+2
source

Source: https://habr.com/ru/post/1439491/


All Articles