FIX.Session.Store behaviour (fix_session v0.1.2)

Copy Markdown View Source

Durable sequence-number and outbound-message storage contract.

Summary

Types

sequences()

@type sequences() :: %{next_in: pos_integer(), next_out: pos_integer()}

Callbacks

commit_outbound(store_ref, session_id, seq_num, wire, next_out)

@callback commit_outbound(
  store_ref :: term(),
  session_id :: term(),
  seq_num :: pos_integer(),
  wire :: binary(),
  next_out :: pos_integer()
) :: :ok | {:error, term()}

get_outbound(store_ref, session_id, seq_num)

@callback get_outbound(
  store_ref :: term(),
  session_id :: term(),
  seq_num :: pos_integer()
) ::
  {:ok, binary()} | :error

Fetches the wire bytes stored for seq_num.

:error must mean the message was never stored, and nothing else: the resend path answers it with a SequenceReset-GapFill, telling the counterparty that sequence number carried no business message. An implementation that cannot reach its storage must therefore raise rather than report a gap.

load(store_ref, session_id)

@callback load(store_ref :: term(), session_id :: term()) ::
  {:ok, sequences()} | {:error, term()}

save_inbound(store_ref, session_id, next_in)

@callback save_inbound(
  store_ref :: term(),
  session_id :: term(),
  next_in :: pos_integer()
) :: :ok | {:error, term()}