ExRiak v0.3.1 ExRiak.PBSocket View Source
Wrapper around the :riakc_pb_socket
API.
Link to this section Summary
Functions
Deletes the key/value
Deletes the key/value, raising an error if there’s an issue
Fetches the representation of a convergent data type from Riak
Fetches the representation of a convergent data type from Riak
Gets bucket/key from server
Gets a bucket/key from server
Lists all keys in a bucket
Lists all keys in a bucket
Puts the metadata/value in the object under the bucket/key
Puts the metadata/value in the object under the bucket/key and raises on failure
Creates a linked process to communicate with the riak server
Link to this section Types
client_opt() :: :queue_if_disconnected | {:queue_if_disconnected, boolean()} | {:connect_timeout, pos_integer()} | :auto_reconnect | {:auto_reconnect, boolean()} | :keepalive | {:keepalive, boolean()}
start_link_opt() :: {:hostname, String.t()} | {:port, port_number()} | client_opt()
Link to this section Functions
delete(t(), bucket_locator(), key()) :: :ok | {:error, ExRiak.PBSocketError.t()}
Deletes the key/value.
delete!(t(), bucket_locator(), key()) :: :ok | no_return()
Deletes the key/value, raising an error if there’s an issue.
fetch_type(t(), bucket_locator(), key()) :: {:ok, ExRiak.DataType.t()} | {:error, :not_found | ExRiak.PBSocketError.t()}
Fetches the representation of a convergent data type from Riak.
fetch_type!(t(), bucket_locator(), key()) :: ExRiak.DataType.t() | nil | no_return()
Fetches the representation of a convergent data type from Riak.
Returns nil if not found. Raises an ExRiak.PBSocketError
on failure.
get(t(), bucket_locator(), key()) :: {:ok, ExRiak.Object.t()} | {:error, :not_found | ExRiak.PBSocketError.t()}
Gets bucket/key from server
get!(t(), bucket_locator(), key()) :: ExRiak.Object.t() | nil | no_return()
Gets a bucket/key from server.
Returns nil if not found. Raises an ExRiak.PBSocketError
on failure.
Example
This function is especially useful for fetching or creating an object during an Object Update Cycle.
{:ok, conn} = PBSocket.start_link()
obj = PBSocket.get!(conn, "bucket", "key") || Object.new("bucket", "key")
list_keys(t(), bucket_locator()) :: {:ok, [key()]} | {:error, ExRiak.PBSocketError.t()}
Lists all keys in a bucket.
This is a potentially expensive operation and should not be used in production.
list_keys!(t(), bucket_locator()) :: [key()] | no_return()
Lists all keys in a bucket.
Raises an ExRiak.PBSocketError
on failure.
This is a potentially expensive operation and should not be used in production.
put(t(), ExRiak.Object.t()) :: :ok | {:ok, ExRiak.Object.t()} | {:error, ExRiak.PBSocketError.t() | ExRiak.SiblingsError.t()}
Puts the metadata/value in the object under the bucket/key.
put!(t(), ExRiak.Object.t()) :: :ok | ExRiak.Object.t()
Puts the metadata/value in the object under the bucket/key and raises on failure.
start_link(start_link_opts()) :: GenServer.on_start()
Creates a linked process to communicate with the riak server.
Options:
:hostname
- IP/Hostname of the riak server. Defaults to"localhost"
. Can also set default value in application config with:config :ex_riak, default_hostname: "my-riak-host"
:port
- Port of the riak server. Defaults to8087
Can also set default value in application config with:config :ex_riak, default_port: 8087
Additional options are passed directly to
:riak_pb_socket.start_link/3