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 asrepo
: The Ecto Repo module to user for queryingschema
: The EctoJob.JobQueue module to querynotifier
: The name of thePostgrex.Notifications
notifier process
Link to this section Types
Link to this section Functions
handle_demand(integer(), EctoJob.Producer.State.t()) :: {:noreply, [EctoJob.JobQueue.job()], EctoJob.Producer.State.t()}
Dispatch jobs according to the new demand plus any buffered demand.
handle_info(term(), EctoJob.Producer.State.t()) :: {:noreply, [EctoJob.JobQueue.job()], EctoJob.Producer.State.t()}
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.
init(EctoJob.Producer.State.t()) :: {:producer, EctoJob.Producer.State.t()}
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 asrepo
: The Ecto Repo module to user for queryingschema
: The EctoJob.JobQueue module to querynotifier
: The name of thePostgrex.Notifications
notifier process