Elixir worker for Faktory (blog) (github).
The package can be installed by adding faktory_worker_ex
to your list of dependencies in mix.exs
:
def deps do
[
{:faktory_worker_ex, "~> 0.0"}
]
end
# For enqueuing jobs
defmodule MyFaktoryClient do
use Faktory.Client, otp_app: :my_cool_app
end
# For processing jobs
defmodule MyFaktoryWorker do
use Faktory.Worker, otp_app: :my_cool_app
end
# You must add them to your app's supervision tree
defmodule MyCoolApp.Application do
use Application
def start(_type, _args) do
children = [MyFaktoryClient, MyFaktoryWorker]
Supervisor.start_link(children, strategy: :one_for_one)
end
end
defmodule MyGreeterJob do
use Faktory.Job
def perform(greeting, name) do
IO.puts("#{greeting}, #{name}!!")
end
end
# List argument must match the arity of MyGreeterJob.perform
MyGreeterJob.perform_async(["Hello", "Genevieve"])
mix faktory
You should see logging output and the above job being processed.
mix faktory -h
To see command line options that can override in-app configuration.
iex -S mix faktory
If you want to debug your jobs using IEx.pry
.
Compile-time config is done with Mix.Config
.
Run-time config is done with environment variables and/or an init/1
callback.
See documentation on:
To run this readme's example, you need to run a Faktory server.
Easiest way is with Docker:
docker run --rm -p 7419:7419 -p 7420:7420 contribsys/faktory:latest -b :7419 -w :7420
You should be able to go to http://localhost:7420 and see the web ui.
- Middleware
- Connection pooling (for clients)
- Support for multiple Faktory servers
- Faktory server authentication and TLS support
- Comprehensive documentation
- Comprehensive supervision tree
- Decent integration tests
- Responding to
quiet
andterminate
- Running without
mix
(e.g. a Distillery release)