Module resty.riak.client
“Low level” riak client.
Just a thin wrapper over the “raw” protocol buffers. This API may change and should not be considered stable. It may change between major versions. While not “private”, just be aware it may change. Only the high-level API is considered stable.
Functions
new () | Creates a riak object. |
set_timeout (self, timeout) | Sets the timeout protection for subsequent operations, including the connect method. |
connect (self, host, port) | Attempts to connect to the remote host and port. |
set_keepalive (self, timeout, size) | Keeps the current riak connection alive and put it into the ngx_lua cosocket connection pool. |
store_object (self, bucket, object) | Store a “raw” riak object. |
delete_object (self, bucket, key, options) | Delete an object. |
get_object (self, bucket, key) | Retrieve an object. |
ping (self) | “Ping” the riak server. |
get_client_id (self) | Retrieve client id. |
get_server_info (self) | “Ping” the riak server. |
get_bucket_props (self, bucket) | Get bucket properties |
set_bucket_props (self, bucket, properties) | Get bucket properties |
get_index (self, bucket, index, value) | Query a secondary index |
update_counter (self, bucket, key, amount, options) | Update a counter |
get_counter (self, bucket, key) | Get the value of a counter Update a counter |
Functions
- new ()
-
Creates a riak object.
Returns:
-
riak.resty.client
“low level” client object
- set_timeout (self, timeout)
-
Sets the timeout protection for subsequent operations, including the connect method.
Parameters:
- self resty.riak.client
- timeout number in milliseconds
- connect (self, host, port)
-
Attempts to connect to the remote host and port.
Before actually resolving the host name and connecting to the remote backend,
this method will always look up the connection pool for matched idle connections
created by previous calls of this method.
Parameters:
- self resty.riak.client
- host string see tcpsock:connect
- port number see tcpsock:connect
Returns:
- boolean not true on error
- string error description
- set_keepalive (self, timeout, size)
-
Keeps the current riak connection alive and put it into the ngx_lua cosocket connection pool.
You can specify the max idle timeout when the connection is in the pool and the maximal size of the pool every nginx worker process.
Parameters:
- self resty.riak.client
- timeout number in milliseconds see tcpsock:setkeepalive
- size number the maximal number of connections allowed in the connection pool for the current server. see tcpsock:setkeepalive
Returns:
- boolean not true on error
- string error description
- store_object (self, bucket, object)
-
Store a “raw” riak object. The definition of a riak object is defined
in the riak PBC as RpbContent.
Parameters:
- self resty.riak.client
- bucket string
- object table in the form of RpbContent
Returns:
- boolean not true on error
- string error description
Usage:
local object = { key = "1", content = { value = "test", content_type = "text/plain" } } local rc, err = client:store_object("bucket-name", object) -- if using eleveldb, secondary indexes can be added to object before storing local object = { key = "1", content = { { value = "test", content_type = "text/plain", indexes = { { key = "foo_bin", value = "bar" } } } }}
- delete_object (self, bucket, key, options)
-
Delete an object.
Parameters:
- self resty.riak.client
- bucket string
- key string
- options table optional parameters as defined in PBC Delete Object
Returns:
- boolean not true on error. If an object does not exist and there is no other error (network, time out, etc) then this will still return true.
- string error description
- get_object (self, bucket, key)
-
Retrieve an object.
Parameters:
- self resty.riak.client
- bucket string
- key string
Returns:
-
table
RpbContent. If not found, then
nil
. -
string
error description. If not found,
not found
will be returned.
- ping (self)
-
“Ping” the riak server.
Parameters:
- self resty.riak.client
Returns:
- boolean not true on error.
- string error description
- get_client_id (self)
-
Retrieve client id.
Parameters:
- self resty.riak.client
Returns:
- get_server_info (self)
-
“Ping” the riak server.
Parameters:
- self resty.riak.client
Returns:
- table info as defined in RpbGetServerInfoResp
- string error description
- get_bucket_props (self, bucket)
-
Get bucket properties
Parameters:
- self resty.riak.client
- bucket string
Returns:
- table properties as defined in RpbBucketProps
- string error description
- set_bucket_props (self, bucket, properties)
-
Get bucket properties
Parameters:
- self resty.riak.client
- bucket string
- properties table as defined in set-bucket-props
Returns:
- boolean successful
- string error description
- get_index (self, bucket, index, value)
-
Query a secondary index
Parameters:
- self resty.riak.client
- bucket string
- index string
- value If this is a string, this is an exact match query, if a table then it is a range query
- update_counter (self, bucket, key, amount, options)
-
Update a counter
Parameters:
- self resty.riak.client
- bucket string
- key string
- amount number amount to incremenent counter
- options
table
currently only
returnvalue
is supported
Returns:
- value value of counter
- string error description
- get_counter (self, bucket, key)
-
Get the value of a counter
Update a counter
Parameters:
- self resty.riak.client
- bucket string
- key string
Returns:
- value value of counter
- string error description