honeydew v1.0.0-rc6 Honeydew

Summary

Functions

async(task, queue, opts \\ [])
cancel(job)
filter(queue, function)
queue_spec(name, opts \\ [])

Creates a supervision spec for a queue.

name is how you’ll refer to the queue to add a task.

You can provide any of the following opts:

  • queue: is the module that queue will use, you may also provide init/1 args: {module, args}
  • dispatcher: the job dispatching strategy, {module, init_args}.
  • failure_mode: the way that failed jobs should be handled. You can pass either a module, or {module, args}, the module must implement the Honeydew.FailureMode behaviour. args defaults to [].
  • supervisor_opts: options accepted by Supervisor.Spec.supervisor/3.

For example: Honeydew.queue_spec("my_awesome_queue") Honeydew.queue_spec("my_awesome_queue", queue: {MyQueueModule, [ip: "localhost"]}, dispatcher: {Honeydew.Dispatcher.MRU, []})

resume(queue)
state(queue)
status(queue)
suspend(queue)
worker_spec(name, module_and_args, opts \\ [])

Creates a supervision spec for workers.

queue is the name of the queue that the workers pull jobs from module is the module that the workers in your queue will use, you may also provide init/1 args: {module, args}

You can provide any of the following opts:

  • num: the number of workers to start
  • init_retry: the amount of time, in milliseconds, to wait before respawning a worker who’s init/1 function failed
  • shutdown: if a worker is in the middle of a job, the amount of time, in milliseconds, to wait before brutally killing it.
  • supervisor_opts options accepted by Supervisor.Spec.supervisor/3.
  • nodes: for :global queues, you can provide a list of nodes to stay connected to (your queue node and enqueuing nodes)

For example: Honeydew.worker_spec("my_awesome_queue", MyJobModule) Honeydew.worker_spec("my_awesome_queue", {MyJobModule, [key: "secret key"]}, num: 3) Honeydew.worker_spec({:global, "my_awesome_queue"}, MyJobModule, nodes: [:clientfacing@dax, :queue@dax])

yield(job, timeout \\ 5000)