FixAlchemy.Feed (FIXAlchemy v0.3.0)
View SourcePublishes one price to many sessions, applying each venue transform once.
A subscription is a symbol and an ordered path of permission stages. Paths sharing a prefix share the computation of that prefix: the stages form a tree, a published price walks it from the root, each stage is applied once however many sessions lie beneath it, and every node hands its value to the sessions subscribed at exactly that node.
path = [{:stream, "SUPERFINE"}, {:spread, :tier_a}, {:markup, 1.2}]
FixAlchemy.Feed.subscribe("AUD/USD", path, md_req_id)
FixAlchemy.Feed.publish("AUD/USD", {:stream, "SUPERFINE"}, price_id, price, MyVenue.Prices)A subscriber receives, for each node it is subscribed to:
{:feed, %{symbol: symbol, price_id: price_id, price: price, ref: ref}}price is the value as it reached that node. price_id identifies the source
price and is the same for every session the publish reaches, whatever
transforms were applied. ref is the term given at subscribe time. The path
is not delivered.
Stages
A stage is any comparable term. Two subscriptions share a node only when their
stages compare equal, so a stage names a transform rather than being one:
{:markup, 1.2} and not fn price -> price * 1.2 end, which produces an
unequal term each time it is written and would split a node that should be
shared.
The venue turns a stage into a computation through
FixAlchemy.Feed.Pipeline.apply_stage/2.
Stages must be ordered consistently across subscriptions. [a, b] and
[b, a] are different paths sharing no work beyond the root, which is
correct — their values differ — but a venue that lets clients order stages
freely fragments its own tree.
Lifetime
Subscribers are monitored; every subscription a process holds is dropped when it exits.
Summary
Functions
Returns a specification to start this module under a supervisor.
The stages reachable directly below this node.
Walk the tree under root, delivering to every subscribed node.
Subscribe the calling process to symbol at path, carrying ref.
The sessions subscribed at exactly this node, as %{pid => ref}.
Remove the calling process's subscription to symbol at path.
Remove every subscription the calling process holds.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
The stages reachable directly below this node.
Walk the tree under root, delivering to every subscribed node.
pipeline is a module implementing FixAlchemy.Feed.Pipeline. Returns the
number of stages applied, which is one per live edge below the root and does
not grow with the number of subscribers.
@spec start_link(term()) :: GenServer.on_start()
Subscribe the calling process to symbol at path, carrying ref.
Subscribing the same process to the same symbol and path again replaces its reference rather than adding a second subscription.
The sessions subscribed at exactly this node, as %{pid => ref}.
Remove the calling process's subscription to symbol at path.
@spec unsubscribe_all() :: :ok
Remove every subscription the calling process holds.