Job Queue v0.1.0 JobQueue.Processor

A basic ConsumerSupervisor setup that works well with JobQueue.Queue and JobQueue.Worker.

Example

iex> # Setup Worker
...> defmodule ProcessorWorker do
...>   def start_link(job = %JobQueue.Job{event: event}) do
...>     Task.start_link(fn ->
...>       JobQueue.Queue.ack(job, {:ok, event})
...>     end)
...>   end
...> end
...>
...> # Start Queue
...> {:ok, _queue} = JobQueue.Queue.start_link(ProcessorQueue)
...>
...> # Setup Processor
...> {:ok, _processor} = Processor.start_link(ProcessorQueue, ProcessorWorker)
...>
...> # Queue a Job
...> JobQueue.Queue.add_sync(ProcessorQueue, :done)
{:ok, :done}

Summary

Functions

Starts a ConsumerSupervisor given a Queue name, the module of a worker and optional options

Functions

start_link(queue, worker_module, options \\ [])

Specs

start_link(term, term, Keyword.t) :: {:ok, pid}

Starts a ConsumerSupervisor given a Queue name, the module of a worker and optional options.

Options

  • max_demand - The maximum demand that will be asked for at once (think the max number of parallel jobs).
  • min_demand - The smallest amount of demand that will be asked for at once, for most queues you will want this to be 1.