faktory_worker_ex v0.5.0 Faktory.Configuration
Configuration options for clients and workers.
Client config is used for enqueuing jobs.
Worker config is used for dequeuing and processing jobs.
Your application may require one or the other… or both.
Defaults
If you don’t configure faktory_worker_ex
at all, it will autoconfigure
itself to connect to a Faktory server on localhost
both client side and
worker side with sane defaults. You can call Faktory.Configuration.all/0
to see these defaults.
Client Configuration
Settings used for enqueuing jobs.
config :faktory_worker_ex, FooConfig,
adapter: Faktory.Configuration.Client
host: "foo_faktory.mycompany.com",
config :faktory_worker_ex, BarConfig
adapter: Faktory.Configuration.Client
host: "bar_faktory.mycompany.com"
Valid options:
host
- Host of Faktory server. Default"localhost"
port
- Port of Faktory server. Default7419
pool
- Connection pool size. Default10
middleware
- Middleware chain. Default[]
password
- For Faktory server authentication. Defaultnil
use_tls
- Connect to Faktory server using TLS. Defaultfalse
Default Client
The first configured client is the “default client” and is used by
Faktory.Job.perform_async/2
when no client is specified.
# No client is specified, default client is used.
MySuperJob.perform_async([1, 2, 3])
# Explicitly specify a client.
MyUltraJob.perform_async([1, 2, 3], client: BarConfig)
Worker Options
config :faktory_worker_ex, FooWorker,
adapter: Faktory.Configuration.Worker,
host: "foo_faktory.mycompany.com"
config :faktory_worker_ex, BarWorker,
adapter: Faktory.Configuration.Worker,
host: "bar_faktory.mycompany.com"
Valid options:
host
- Host of Faktory server. Default"localhost"
port
- Port of Faktory server. Default7419
concurrency
- How many concurrent jobs to process. Default20
pool
- Connection pool size. Default${concurrency}
middleware
- Middleware chain. Default[]
queues
- List of queues to fetch from. Default["default"]
Runtime Configuration
There are two ways to do runtime configuration:
- The conventional tuple syntax to read environment vars
- Using a callback function
Environment var without default value:
config :faktory_worker_ex, MyClient,
adapter: Faktory.Configuration.Client,
host: {:system, "FAKTORY_HOST"}
Environment var with default value:
config :faktory_worker_ex, MyClient,
adapter: Faktory.Configuration.Client,
host: {:system, "FAKTORY_HOST", "localhost"}
Using a callback:
config :faktory_worker_ex, MyClient,
adapter: Faktory.Configuration.Client,
defmodule MyClient do
use Faktory.Configuration.Client
def init(config) do
Keyword.put(config, :host, "faktory.company.com")
end
end
Link to this section Summary
Link to this section Functions
Return all configuration modules and their options.
This is more or less a debugging function.