shigoto_config (shigoto v1.9.10)

View Source

Configuration access for Shigoto. Reads from application env.

Summary

Functions

Days to keep archived jobs before permanent deletion. Default: 90.

Cron job entries. Each is {Name, Schedule, Worker, Args} or {Name, Schedule, Worker, Args, #{timezone => Timezone}}.

AES-256-GCM encryption key for job args/meta. Returns undefined if not configured.

Ordered list of encryption keys (newest first) for key rotation. Default: [].

Queues that use fair partition-based claiming. Default: [] (all use standard claiming).

Fanout queues — every node processes every job. Format: [{QueueName, Concurrency, Opts}] where Opts may include window (seconds, default 120). Default: [].

Heartbeat interval in milliseconds for executing jobs. Default: 30000.

Load shedding config. Default: undefined (disabled).

Global middleware chain applied to all jobs. Default: [].

Database connection config for LISTEN/NOTIFY. Returns undefined if not configured.

Poll interval in milliseconds. Default: 5000.

The minato pool name for job storage. Set repo for Kura-based apps or pool for a pool of its own.

Days to keep completed/discarded jobs before archiving. Default: 14.

Queue weight config. Map of queue name to weight. Default: #{} (equal weight).

Configured queue names and concurrency. Default: [{<<"default">>, 10}].

Milliseconds to wait for in-flight jobs during shutdown. Default: 15000.

Stager interval in milliseconds for surfacing newly-due scheduled/retryable jobs. Default: 1000.

Testing mode for insert/1,2 and insert_all/1,2. Default: disabled (normal production behaviour — jobs are persisted and run by queue workers).

Functions

archive_after_days()

-spec archive_after_days() -> pos_integer().

Days to keep archived jobs before permanent deletion. Default: 90.

cron_entries()

-spec cron_entries() -> list().

Cron job entries. Each is {Name, Schedule, Worker, Args} or {Name, Schedule, Worker, Args, #{timezone => Timezone}}.

Timezone may be:

  • utc (the default when omitted)
  • an integer hour offset, e.g. 2 or -5
  • a "+/-N" or "UTC" binary, e.g. <<"+2">>
  • a named IANA zone, e.g. <<"Europe/Stockholm">>, resolved (with DST) for each instant against the operating system's time zone database

encryption_key()

-spec encryption_key() -> binary() | undefined.

AES-256-GCM encryption key for job args/meta. Returns undefined if not configured.

encryption_keys()

-spec encryption_keys() -> [binary()].

Ordered list of encryption keys (newest first) for key rotation. Default: [].

fair_queues()

-spec fair_queues() -> [binary()].

Queues that use fair partition-based claiming. Default: [] (all use standard claiming).

fanout_queues()

-spec fanout_queues() -> [{binary(), pos_integer(), map()}].

Fanout queues — every node processes every job. Format: [{QueueName, Concurrency, Opts}] where Opts may include window (seconds, default 120). Default: [].

heartbeat_interval()

-spec heartbeat_interval() -> pos_integer().

Heartbeat interval in milliseconds for executing jobs. Default: 30000.

load_shedding()

-spec load_shedding() -> map() | undefined.

Load shedding config. Default: undefined (disabled).

middleware()

-spec middleware() -> [shigoto_middleware:middleware()].

Global middleware chain applied to all jobs. Default: [].

notifier_config()

-spec notifier_config() -> map() | undefined.

Database connection config for LISTEN/NOTIFY. Returns undefined if not configured.

poll_interval()

-spec poll_interval() -> pos_integer().

Poll interval in milliseconds. Default: 5000.

pool()

-spec pool() -> atom().

The minato pool name for job storage. Set repo for Kura-based apps or pool for a pool of its own.

prune_after_days()

-spec prune_after_days() -> pos_integer().

Days to keep completed/discarded jobs before archiving. Default: 14.

queue_weights()

-spec queue_weights() -> #{binary() => pos_integer()}.

Queue weight config. Map of queue name to weight. Default: #{} (equal weight).

queues()

-spec queues() -> [{binary(), pos_integer()}].

Configured queue names and concurrency. Default: [{<<"default">>, 10}].

shutdown_timeout()

-spec shutdown_timeout() -> pos_integer().

Milliseconds to wait for in-flight jobs during shutdown. Default: 15000.

stage_interval()

-spec stage_interval() -> pos_integer().

Stager interval in milliseconds for surfacing newly-due scheduled/retryable jobs. Default: 1000.

testing_mode()

-spec testing_mode() -> disabled | inline | manual.

Testing mode for insert/1,2 and insert_all/1,2. Default: disabled (normal production behaviour — jobs are persisted and run by queue workers).

inline executes each inserted job synchronously in the calling process and keeps no database row; manual captures inserted jobs in a process-local buffer for shigoto_testing assertions without persisting or executing them. Both are strictly for tests: they change persistence, so arming them requires TWO keys —

application:set_env(shigoto, testing, inline),          %% or manual
application:set_env(shigoto, testing_confirm_no_persistence, true).

A non-disabled testing value WITHOUT the confirmation key does NOT arm the mode: it falls back to the real persisted path and logs an error, so a testing config that leaks into production fails safe and loud rather than silently dropping jobs.