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. Default 7419
  • pool - Connection pool size. Default 10
  • middleware - Middleware chain. Default []
  • password - For Faktory server authentication. Default nil
  • use_tls - Connect to Faktory server using TLS. Default false

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. Default 7419
  • concurrency - How many concurrent jobs to process. Default 20
  • 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:

  1. The conventional tuple syntax to read environment vars
  2. 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

Functions

Return all configuration modules and their options

Link to this section Functions

Link to this function all()
all() :: [{module(), map()}]

Return all configuration modules and their options.

This is more or less a debugging function.