View Source ProcessHub.Service.Dispatcher (ProcessHub v0.8.0)
The dispatcher service provides API functions for dispatching events.
Summary
Functions
Sends StartChildrenRequest structs to their target coordinator processes.
Sends StopChildrenRequest structs to their target coordinator processes.
Dispatches an event to the event queue.
Dispatches an event to the event queue without waiting for it.
Propagates a request to cluster members via the synchronization strategy.
Sends a message to all the respondents who are waiting for a response.
Sends requests to the worker queues of members over the channel every
request travels, so on each node they run after every request sent there
before them from this node.
Returns the nodes this node recently sent a start for child_id to, and
forgets them, so the same stop is not forwarded twice. A target that has
since left the cluster is dropped: a stop sent there is never answered, and
the child it may have started went with it.
Functions
@spec children_start( ProcessHub.Hub.t(), [ProcessHub.Request.Handler.StartChildrenRequest.t()], keyword() ) :: :ok
Sends StartChildrenRequest structs to their target coordinator processes.
Each StartChildrenRequest contains all routing information needed by the
remote node to process the request and send responses back. Options are
those of send_requests/4.
@spec children_stop( ProcessHub.Hub.t(), [ProcessHub.Request.Handler.StopChildrenRequest.t()], keyword() ) :: :ok
Sends StopChildrenRequest structs to their target coordinator processes.
Each StopChildrenRequest contains all routing information needed by the
remote node to process the request and send responses back. Options are
those of send_requests/4.
@spec dispatch_event(atom(), atom(), term(), %{ optional(:discard_event) => boolean(), optional(:members) => :global | :local | :external | [node()] }) :: {:ok, :event_discarded | :event_dispatched | :event_queued}
Dispatches an event to the event queue.
dispatch_event_async(event_queue, event_id, event_data, opts \\ %{})
View Source@spec dispatch_event_async(atom(), atom(), term(), %{ optional(:discard_event) => boolean(), optional(:members) => :global | :local | :external | [node()] }) :: :ok
Dispatches an event to the event queue without waiting for it.
The event queue sends to every member in turn, so a peer whose connection
has stopped draining holds it until the connection recovers or drops. The
coordinator uses this for its own events so it never waits on such a peer.
Events sent from one process keep their order, also relative to the ones it
sends with dispatch_event/4.
The queue is bounded: past 10000 waiting events the sender
waits for it as with dispatch_event/4, so a stalled peer slows the sender
down instead of growing the queue without limit. The wait ends after the
queue's own call timeout; the event stays queued.
@spec propagate_event(ProcessHub.Hub.t(), struct(), keyword()) :: :ok
Propagates a request to cluster members via the synchronization strategy.
Options
:members- Target members (:global,:local,:external, or[node()]). Defaults to:global.:async- seesend_requests/4. Defaults tofalse.
@spec reply_respondents([pid()], atom(), ProcessHub.child_id(), term(), node()) :: :ok
Sends a message to all the respondents who are waiting for a response.
@spec send_requests( ProcessHub.Hub.t(), [struct()], :global | :local | :external | [node()], keyword() ) :: :ok
Sends requests to the worker queues of members over the channel every
request travels, so on each node they run after every request sent there
before them from this node.
Options
:async- whentrue, hands the requests to the event queue without waiting (dispatch_event_async/4), for the coordinator's own paths. Defaults tofalse.
@spec take_start_targets(ProcessHub.Hub.t(), ProcessHub.child_id()) :: [node()]
Returns the nodes this node recently sent a start for child_id to, and
forgets them, so the same stop is not forwarded twice. A target that has
since left the cluster is dropped: a stop sent there is never answered, and
the child it may have started went with it.