Rihanna v2.1.1 Rihanna.Config View Source

Global configuration for Rihanna.

Sensible defaults have been chosen for you but if you want, you can optionally override any of these values in your local configuration.

For example, to change the table name for jobs:

config :rihanna, jobs_table_name: "awesome_jobs"

Link to this section Summary

Functions

Restricts Rihanna to only running jobs that conform to the Rihanna behaviour.

Toggle debug logging.

The maximum number of simultaneously executing workers for a dispatcher.

How often the dispatcher should poll the database for new jobs (in milliseconds).

The table name to use for Rihanna jobs.

Specify the classid to use for advisory locks.

Specifies the Postgres database connection to use when enqueuing, scheduling, and deleting jobs. When set the Rihanna.Supervisor will not start a dedicated Postgrex connection process for these operations.

Use a startup delay to avoid killing the supervisor if we can't connect to the database for some reason. Value is in milliseconds.

Link to this section Functions

Restricts Rihanna to only running jobs that conform to the Rihanna behaviour.

Being able to call Rihanna with mod-fun-args is convenient but presets a very slight increase in attack surface area. Some people may want to turn this off, which you can do by setting this option to true.

Example

config :rihanna, behaviour_only: true

Toggle debug logging.

Rihanna logs nothing by default. By configuring Rihanna with debug: true and setting Logger's log level to :debug, you can get much more information about what it is doing during operation to troubleshoot issues.

Example

config :rihanna, debug: true
Link to this function

dispatcher_max_concurrency()

View Source

The maximum number of simultaneously executing workers for a dispatcher.

50 is chosen as a sensible default. Tuning this might increase or decrease your throughput depending on a lot of factors including database churn and how many other dispatchers you are running.

Example

config :rihanna, dispatcher_max_concurrency: 25
Link to this function

dispatcher_poll_interval()

View Source

How often the dispatcher should poll the database for new jobs (in milliseconds).

Default is 100.

Note that that actual poll interval in practice will be close to but not exactly this number of milliseconds for two reasons:

  1. A small amount of processing time for dispatching jobs is not included and will be added to the poll interval.
  2. A small, random amount of jitter is added to prevent multiple dispatchers started simultaneously from hitting the database at the same time.

Example

config :rihanna, dispatcher_poll_interval: :timer.seconds(1)

The table name to use for Rihanna jobs.

config :rihanna, jobs_table_name: "my_jobs"
Link to this function

pg_advisory_lock_class_id()

View Source

Specify the classid to use for advisory locks.

Details

In Postgres, advisory locks are scoped to a classid.

Here we use a random classid to prevent potential collisions with other users of the advisory locking system.

In the unimaginably unlucky scenario that this conflicts with a lock classid that is already being used on your system, you can change the classid that Rihanna uses here.

Example

config :rihanna, pg_advisory_lock_class_id: 42
Link to this function

producer_postgres_connection()

View Source

Specifies the Postgres database connection to use when enqueuing, scheduling, and deleting jobs. When set the Rihanna.Supervisor will not start a dedicated Postgrex connection process for these operations.

If you application uses Ecto you can re-use your Ecto Repo here.

Examples

# Use a user-started Postgres connection process
# `:my_postgrex_connection` is a named process started with [`Postgrex.start_link/1`](https://hexdocs.pm/postgrex/0.15.1/Postgrex.html#start_link/1).
config :rihanna, producer_postgres_connection: {Postgrex, :my_postgrex_connection}
# Use an Ecto Repo
config :rihanna, producer_postgres_connection: {Ecto, MyApp.Repo}

Use a startup delay to avoid killing the supervisor if we can't connect to the database for some reason. Value is in milliseconds.

Defaults to 0 for test env and 5000ms for other envs.

Example

config :rihanna, startup_delay: :timer.milliseconds(500)