Routemaster Client v0.3.0 Routemaster.Drains.Siphon View Source
Allows to pluck events for one or more topics and remove them
from the current payload. The removed — siphoned — events
are sent to a siphon module that must implement the call/1
function, that will be invoked with a list of Routemaster.Drain.Event
structures as argument.
The siphons’ call/1
function is invoked in a supervised Task
,
so all siphons are to be considered asynchronous and independent.
This drain plug is very similar to the Routemaster.Drains.Notify
module, with the difference that it modifies the event list in the
current payload before passing it downstream to the next drain in
the pipeline.
It’s meant to be used when some topic should not be processed
with the rest of the drain pipeline, and you want to extract
it from the stream before it reaches the next drains.
A common use case is when you care about every single event
for a topic (e.g. fast changing resources where each event
carries a data payload), and these need to be processed
separately before a Routemaster.Drains.Dedup
or
Routemaster.Drains.IgnoreStale
drain can discard any of them.
Options
:topic
(or:topics
, plural): either a binary or a list of binaries. This is the topic or topics that will be removed from the current payload and sent to the siphon module.:to
: the siphon module that will receive the events.
Examples
alias Routemaster.Drains.Siphon
drain Siphon, topic: "burgers", to: BurgerSiphon
drain Siphon, topics: ~w(coke fanta), to: DrinksSiphon