View Source Dynamo.Client (Dynamo v0.2.0)

Low-level DynamoDB HTTP client: SigV4 signing, retries with jittered exponential backoff, error normalisation and telemetry.

You normally don't call this directly – Dynamo.Repo does. It is exposed for tooling (mix tasks) and for people who want to send raw requests.

client = Dynamo.Client.new(region: "eu-west-1", credentials: creds)
Dynamo.Client.request(client, "ListTables", %{})
#=> {:ok, %{"TableNames" => [...]}}

Options

  • :region – required
  • :endpoint – full URL; defaults to https://dynamodb.<region>.amazonaws.com
  • :search_endpoint – endpoint for SearchVectors, which AWS serves from a separate host; defaults to https://search-dynamodb.<region>.amazonaws.com. When a custom :endpoint is given (DynamoDB Local, a proxy), it is used for search too unless :search_endpoint is set explicitly.
  • :credentials – %Dynamo.Credentials{} or {:cache, pid_or_name} of a Dynamo.Credentials.Cache (used by repos so credentials refresh automatically)
  • :max_retries – default 3 (only retryable errors are retried)
  • :base_backoff_ms – default 50; delay = random(0, base * 2^attempt) capped at :max_backoff_ms (default 5_000)
  • :receive_timeout – default 30_000
  • :connect_timeout – default 5_000
  • :req_options – extra options merged into every Req call (e.g. plug: for tests)
  • :telemetry_prefix – default [:dynamo]

Telemetry

[prefix, :request, :start | :stop | :exception] with measurements %{duration: native} on stop and metadata:

%{action: "Query", table: "app" | nil, attempt: 1, result: :ok | :error,
  error: %Dynamo.Error{} | nil, status: 200, consumed_capacity: map | nil}

Summary

Functions

Builds a client. Raises on missing :region or :credentials.

Sends a DynamoDB action. Returns the decoded JSON body or a normalised error.

Types

t()

@type t() :: %Dynamo.Client{
  base_backoff_ms: term(),
  connect_timeout: term(),
  credentials: term(),
  endpoint: term(),
  max_backoff_ms: term(),
  max_retries: term(),
  receive_timeout: term(),
  region: term(),
  req_options: term(),
  search_endpoint: term(),
  telemetry_prefix: term()
}

Functions

new(opts)

@spec new(keyword()) :: t()

Builds a client. Raises on missing :region or :credentials.

request(client, action, payload)

@spec request(t(), String.t(), map()) :: {:ok, map()} | {:error, Dynamo.Error.t()}

Sends a DynamoDB action. Returns the decoded JSON body or a normalised error.