Counterpoint.CommandRunner (counterpoint v0.1.0)

Copy Markdown View Source

Executes a Counterpoint.Command with automatic optimistic-concurrency retry.

On {:error, :append_condition_failed} (concurrent write detected) the command is retried up to max_attempts times using exponential back-off starting at 50 ms. All other errors are returned immediately.

Example

Counterpoint.CommandRunner.run(:my_store, %MyApp.Commands.PlaceOrder{order_id: "1", total: 42})
# => {:ok, _} | {:error, reason}

# custom retry limit
Counterpoint.CommandRunner.run(:my_store, cmd, max_attempts: 6)

Summary

Functions

Run command against the store registered under store_name.

Functions

run(store_name, command, opts \\ [])

Run command against the store registered under store_name.

Options

  • :max_attempts – maximum number of attempts including the first (default: 4).