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. Default 7419
  • password - Faktory server password. Default nil
  • config_fn - Callback function for runtime config. Default nil

Client Options

  • pool - Client connection pool size. Default 10
  • 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. Default 20
  • 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

Functions

Get client or worker config

Fetch all configuration

Fetch client or worker configs

Link to this section Functions

Link to this function fetch(type, name \\ :default)
fetch(:client | :worker, atom()) :: struct()

Get client or worker config.

Resolves all the values from Mix Config, runs any runtime config callbacks, and returns a struct representing the config.

Link to this function fetch_all()
fetch_all() :: [struct()]

Fetch all configuration.

Returns both client and worker configs.

Link to this function fetch_all(type)
fetch_all(:client | :worker) :: [struct()]

Fetch client or worker configs.