faktory_worker_ex v0.4.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
use Mix.Config
config :faktory_worker_ex,
host: "localhost",
port: 7419,
client: [
pool: 10,
],
worker: [
concurrency: 20,
queues: ["default"],
]
Notice that client/worker specific options will inherit from top level options
where applicable. In the above example, client.host
will be "localhost"
.
Options
host
- Faktory server host. Default"localhost"
port
- Faktory server port. Default7419
password
- Faktory server password. Defaultnil
config_fn
- Callback function for runtime config. Defaultnil
Client Options
pool
- Client connection pool size. Default10
middleware
- Client middleware chain. Default[]
Worker Options
pool
- Worker connection pool size. Default${concurrency}
middleware
- Worker middleware chain. Default[]
concurrency
- How many worker processes to start. Default20
queues
- List of queues to fetch from. Default["default"]
Runtime Configuration
You can specify a callback to do runtime configuration. For example, to read host and port from environment variables.
config :faktory_worker_ex,
config_fn: &FaktoryConfig.call/1
defmodule FaktoryConfig do
def call(config) do
%{ config |
host: System.get_env("FAKTORY_HOST"),
port: System.get_env("FAKTORY_PORT") }
end
end
The function takes a config struct and returns a config struct.
Example
config :faktory_worker_ex,
host: "faktory.company.com",
client: [
pool: 5,
middleware: [Statsd]
],
worker: [
concurrency: 10,
queues: ["priority01", "priority02", "priority03"]
]
Link to this section Summary
Link to this section Functions
Get client or worker config.
Resolves all the values from Mix Config, runs any runtime config callbacks, and returns a struct representing the config.
Fetch all configuration.
Returns both client and worker configs.
Fetch client or worker configs.