Conqueuer.Foreman

The foreman is responsible for coordinating the arrival, performance and finishing of work.

When :work_arrived the foreman begins to drain the queue and continues until either the queue is empty or the worker pool is exhausted at which point it stops draining. When a worker is :finished the foreman checks the worker back into the worker queue and begins to drain the queue again.

You do not have to define a foreman, only add a registered foreman process with the correct name to your supervision tree.

Given a work queue named :resolvers:

defmodule MyApp do
  use Application

  def start(_type, _args) do
    import Supervisor.Spec, warn: false

    children = [
      ...
      worker(Conqueuer.Foreman, [[name: :resolvers], [name: :ResolversForeman]])
    ]

    opts = [ strategy: :one_for_one, name: MyApp.Supervisor ]
    Supervisor.start_link(children, opts)
  end
end

Summary

Functions

Notifies the Foreman work has finished

Notifies the Foreman work has arrived

Functions

finished(foreman, worker)

Notifies the Foreman work has finished.

start_link(args \\ [], opts \\ [])

Starts the Foreman.

work_arrived(foreman)

Notifies the Foreman work has arrived.