View Source OddJob.Queue (OddJob v0.5.1)

The OddJob.Queue is a GenServer that manages the assignments given to the pool workers.

The queue receives jobs and assigns them to available workers. If all workers in a pool are currently busy then new jobs are added to a FIFO queue to be processed as workers become available.

Link to this section Summary

Types

t()

The OddJob.Queue struct holds the state of the job queue.

Link to this section Types

Specs

job() :: OddJob.Job.t()

Specs

queue() :: {:via, Registry, {OddJob.Registry, {atom(), :queue}}}

Specs

t() :: %OddJob.Queue{
  assigned: [pid()],
  jobs: [job()],
  pool: atom(),
  workers: [pid()]
}

The OddJob.Queue struct holds the state of the job queue.

  • :pool is a term representing the name of the job pool that the queue belongs to

  • :workers is a list of the active worker pids, whether they are busy working or not

  • :assigned is a list of the worker pids that are currently assigned to a job

  • :jobs is a list of OddJob.Job structs representing the jobs that are queued to be performed when workers are available

Specs

worker() :: pid()