Quantum v2.2.0 Quantum.JobBroadcaster View Source

This Module is here to broadcast added / removed tabs into the execution pipeline.

Link to this section Summary

Functions

Invoked on :producer stages

Start Job Broadcaster

Link to this section Functions

Link to this function handle_demand(demand, state) View Source

Invoked on :producer stages.

This callback is invoked on :producer stages with the demand from consumers/dispatcher. The producer that implements this callback must either store the demand, or return the amount of requested events.

Must always be explicitly implemented by :producer stages.

Examples

def handle_demand(demand, state) do
  # We check if we're able to satisfy the demand and fetch
  # events if we aren't.
  events =
    if length(state.events) >= demand do
      state.events
    else
      # fetch_events()
    end

  # We dispatch only the requested number of events.
  {to_dispatch, remaining} = Enum.split(events, demand)

  {:noreply, to_dispatch, %{state | events: remaining}}
end

Callback implementation for GenStage.handle_demand/2.

Start Job Broadcaster

Arguments

  • name - Name of the GenStage
  • jobs - Array of Quantum.Job