Coffrify.Runtime.Idempotency behaviour (Coffrify v0.9.0)

View Source

Behaviour for Idempotency-Key persistence — survives crashes between retry attempts.

Bundled adapters:

Summary

Functions

Deterministic key for the same logical request — beats random UUIDs for crash recovery.

Dispatch helper used by Coffrify.Client. Accepts either a {module, state} tuple or a tagged struct whose first element is the module.

Callbacks

delete(any, key)

@callback delete(any(), key :: String.t()) :: :ok

get(any, key)

@callback get(any(), key :: String.t()) :: {:ok, term()} | :miss

put(any, key, value, ttl_ms)

@callback put(any(), key :: String.t(), value :: term(), ttl_ms :: pos_integer()) :: :ok

Functions

delete(state, key)

@spec delete(any(), String.t()) :: :ok

deterministic_key(method, path, body \\ nil)

@spec deterministic_key(String.t(), String.t(), term()) :: String.t()

Deterministic key for the same logical request — beats random UUIDs for crash recovery.

get(state, key)

@spec get(any(), String.t()) :: {:ok, term()} | :miss

Dispatch helper used by Coffrify.Client. Accepts either a {module, state} tuple or a tagged struct whose first element is the module.

put(state, key, value, ttl)

@spec put(any(), String.t(), term(), pos_integer()) :: :ok