ExRiak v0.4.0 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

Link to this type bucket_locator() View Source
bucket_locator() :: ExRiak.bucket_locator()
Link to this type client_opt() View Source
client_opt() ::
  :queue_if_disconnected |
  {:queue_if_disconnected, boolean()} |
  {:connect_timeout, pos_integer()} |
  :auto_reconnect |
  {:auto_reconnect, boolean()} |
  :keepalive |
  {:keepalive, boolean()}
Link to this type client_opts() View Source
client_opts() :: [client_opt()]
Link to this type index_opt() View Source
index_opt() ::
  {:timeout, timeout()} |
  {:call_timeout, timeout()} |
  {:stream, boolean()} |
  {:continuation, ExRiak.SecondaryIndex.continuation()} |
  {:pagination_sort, binary()} |
  {:max_results, non_neg_integer()} |
  :all
Link to this type port_number() View Source
port_number() :: 0..65535
Link to this type range_index_opt() View Source
range_index_opt() :: {:return_terms, boolean()} | index_opt()
Link to this type secondary_index_id() View Source
secondary_index_id() :: ExRiak.SecondaryIndex.index_id()
Link to this type secondary_index_value() View Source
secondary_index_value() :: ExRiak.SecondaryIndex.index_value()

Link to this section Functions

Link to this function delete(pid, bucket_locator, key) View Source
delete(t(), bucket_locator(), key()) ::
  :ok |
  {:error, ExRiak.PBSocketError.t()}

Deletes the key/value.

See :riakc_pb_socket.delete/3.

Link to this function delete!(pid, bucket_locator, key) View Source
delete!(t(), bucket_locator(), key()) :: :ok | no_return()

Deletes the key/value, raising an error if there’s an issue.

See :riakc_pb_socket.delete/3.

Link to this function fetch_type(pid, bucket_locator, key) View Source
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.

See :riakc_pb_socket.fetch_type/3.

Link to this function fetch_type!(pid, bucket_locator, key) View Source
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.

See :riakc_pb_socket.fetch_type/3.

Link to this function get(client, bucket_locator, key) View Source
get(t(), bucket_locator(), key()) ::
  {:ok, ExRiak.Object.t()} |
  {:error, :not_found | ExRiak.PBSocketError.t()}

Gets bucket/key from server

See :riakc_pb_socket.get/3.

Link to this function get!(client, bucket_locator, key) View Source
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")

See :riakc_pb_socket.get/3.

Link to this function get_index_eq(pid, bucket_locator, index_id, key, opts \\ []) View Source

Execute a secondary index query.

See :riakc_pb_socket.get_index_eq/5.

Link to this function get_index_range(pid, bucket_locator, index_id, start_value, end_value, opts \\ []) View Source

Execute a secondary index range query.

See :riakc_pb_socket.get_index_range/6.

Link to this function list_keys(pid, bucket_locator) View Source
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.

See :riakc_pb_socket.list_keys/2.

Link to this function list_keys!(pid, bucket_locator) View Source
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.

See :riakc_pb_socket.list_keys/2.

Link to this function put(client, obj) View Source
put(t(), ExRiak.Object.t()) ::
  :ok |
  {:ok, key()} |
  {:error, ExRiak.PBSocketError.t() | ExRiak.SiblingsError.t()}

Puts the metadata/value in the object under the bucket/key.

When the object’s key is :undefined, riak will generate a key for this object and that key will be returned as a {:ok, key} tuple. If the object’s key is already set, :ok will be returned.

See :riakc_pb_socket.put/2.

Link to this function put!(client, obj) View Source
put!(t(), ExRiak.Object.t()) :: :ok | {:ok, key()} | no_return()

Puts the metadata/value in the object under the bucket/key and raises on failure.

See put/2 for more details.

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 to 8087 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

See :riakc_pb_socket.start_link/3.