FixAlchemy.PubSub behaviour (FIXAlchemy v0.3.0)

View Source

Contract for publishing engine events to interested processes.

Session status changes, and the position, order and account updates the subscriber bases produce, are published through the module configured here. The default is FixAlchemy.PubSub.Phoenix, which forwards to Phoenix.PubSub when it is available; with no server configured, publishing is a no-op and the engine runs unchanged.

config :fix_alchemy,
  pubsub: FixAlchemy.PubSub.Phoenix,
  pubsub_server: MyApp.PubSub

A host that publishes some other way supplies its own module:

defmodule MyApp.FixEvents do
  @behaviour FixAlchemy.PubSub

  @impl FixAlchemy.PubSub
  def broadcast(_server, topic, message) do
    MyApp.Telemetry.emit(topic, message)
    :ok
  end
end

Summary

Callbacks

Publish message on topic.

Functions

Publish message on topic through the configured implementation.

The configured implementation (default FixAlchemy.PubSub.Phoenix).

The engine-wide server name, from config :fix_alchemy, :pubsub_server.

Callbacks

broadcast(server, topic, message)

@callback broadcast(server :: term(), topic :: String.t(), message :: term()) :: :ok

Publish message on topic.

server is the per-session :pubsub_module option, or the value of config :fix_alchemy, :pubsub_server for engine-wide events. Implementations must return :ok and must tolerate a nil server.

Functions

broadcast(server, topic, message)

@spec broadcast(term(), String.t(), term()) :: :ok

Publish message on topic through the configured implementation.

impl()

@spec impl() :: module()

The configured implementation (default FixAlchemy.PubSub.Phoenix).

server()

@spec server() :: term()

The engine-wide server name, from config :fix_alchemy, :pubsub_server.