ecto_job v0.2.0 EctoJob.Producer View Source

GenStage producer responsible for reserving available jobs from a job queue, and passing them on to the consumer module.

The GenStage will buffer demand when there are insufficient jobs available in the database.

Installs a timer to check for expired jobs, and uses a Postgrex.Notifications listener to dispatch jobs immediately when new jobs are inserted into the database and there is pending demand.

Link to this section Summary

Functions

Dispatch jobs according to the new demand plus any buffered demand

Messages from the timer and the notifications listener will be handled in handle_info

Starts the sweeper timer to activate scheduled/expired jobs and starts listening for new job notifications

Starts the producer GenStage process.

  • name : The process name to register this GenStage as
  • repo : The Ecto Repo module to user for querying
  • schema : The EctoJob.JobQueue module to query
  • notifier : The name of the Postgrex.Notifications notifier process

Link to this section Types

Link to this section Functions

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

Dispatch jobs according to the new demand plus any buffered demand.

Messages from the timer and the notifications listener will be handled in handle_info.

If there is no pending demand for jobs, then all messages are ignored. :poll messages will attempt to activate jobs, and dispatch them according to current demand. :notification messages will dispatch any active jobs according to current demand.

Starts the sweeper timer to activate scheduled/expired jobs and starts listening for new job notifications.

Link to this function start_link(list) View Source
start_link(name: atom(), repo: repo(), schema: schema(), notifier: atom()) ::
  {:ok, pid()}

Starts the producer GenStage process.

  • name : The process name to register this GenStage as
  • repo : The Ecto Repo module to user for querying
  • schema : The EctoJob.JobQueue module to query
  • notifier : The name of the Postgrex.Notifications notifier process