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

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 port_number() View Source
port_number() :: 0..65535

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 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.

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

See :riakc_pb_socket.put/2.

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

See :riakc_pb_socket.put/2.

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.