faktory_worker_ex v0.4.0 Faktory.Job
Use this module to create your job processors.
Getting started
All that is required is to define a perform
function that takes zero or more
arguments.
defmodule MyFunkyJob do
use Faktory.Job
def perform(arg1, arg2) do
# ... do something ...
end
end
# To enqueue jobs of this type.
MyFunkyJob.perform_async([1, "foo"])
Notice perform_async
takes a list who’s size must match exactly the airty of
perform
.
Configuring
You can configure various aspects of the job by passing a keyword list to
faktory_options/1
. All keys are optional and their default values are
shown in the example below.
defmodule MyFunkyJob do
use Faktory.Job
faktory_options queue: "default", retry: 25, backtrace: 0
# ...
end
Runtime configuration
You can alter the aspects of a singular job at runtime in a couple of ways.
MyFunkyJob.set(queue: "not_default") |> MyFunkyJob.perform_async([1, "foo"])
That chaining syntax as inspired by the Ruby Faktory Worker and I’m not sure
if it’s a good fit. You can just set options directly in the call to perform_async
:
MyFunkyJob.perform_async([queue: "not_default"], [1, "foo"])
Link to this section Summary
Functions
Set default options for all jobs of this type