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

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 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(pid(), 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!(pid(), 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(pid(), 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!(pid(), 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.

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

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

See :riakc_pb_socket.put/2.

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

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.