FixAlchemy.Session behaviour (FIXAlchemy v0.2.1)
View SourceBase for a per-session handshake subscriber.
use FixAlchemy.Session gives a GenServer that subscribes to the session's
client for the message types it cares about and dispatches each to
handle_fix/4. The defaults implement a plain FIX session: it subscribes to
logon (A) and marks the session ready the moment logon is accepted.
A broker adapter overrides the callbacks with @impl FixAlchemy.Session to add
its own login flow — credentials, account discovery, entitlements — while
reusing everything else:
defmodule MyBroker.Session do
use FixAlchemy.Session
@impl FixAlchemy.Session
def message_types, do: ["A", "BF", "BA"]
@impl FixAlchemy.Session
def handle_fix("A", _raw, meta, state) do
FixAlchemy.Client.send_custom_message(meta.client, {"BE", credentials(state)})
state
end
def handle_fix(type, raw, meta, state), do: super(type, raw, meta, state)
end
Summary
Callbacks
Handle a dispatched message, returning the new state.
Build the session's state from its start options.
Message types this session subscribes to (default ["A"]).
Functions
Subscribe pid to types on the session's client for {connection_id, session_name}.
Callbacks
Handle a dispatched message, returning the new state.
Build the session's state from its start options.
@callback message_types() :: [binary()]
Message types this session subscribes to (default ["A"]).
Functions
@spec subscribe_types(binary(), FixAlchemy.SessionConfig.name(), pid(), [binary()]) :: :ok
Subscribe pid to types on the session's client for {connection_id, session_name}.