Configuration¶
All settings live in Daycry\Jobs\Config\Jobs. Copy the file into your application
(app/Config/Jobs.php, keeping the Config namespace) to override defaults — CodeIgniter’s
service locator favours the application namespace.
Every property documented below exists in the v3 Config\Jobs. Nothing here is invented.
Handlers¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Single source of truth mapping a handler key to a |
|
|
|
Per-queue allowlist of handler keys. A queue listed here may run only the keys it declares. A queue absent from the map (or with an empty list) imposes no restriction — set it explicitly in production so remote queues cannot invoke |
public array $handlers = [
'command' => CommandHandler::class,
'shell' => ShellHandler::class,
'closure' => ClosureHandler::class,
'event' => EventHandler::class,
'url' => UrlHandler::class,
];
// Lock the 'reports' queue to the command handler, and 'web' to url/event only.
public array $queueHandlers = [
'reports' => ['command'],
'web' => ['url', 'event'],
];
Handler Security¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Allowlist of binaries |
|
|
|
Explicit, insecure escape hatch. When |
|
|
|
Allowlist of event names |
// ShellHandler is deny-by-default. Allow specific absolute paths:
public array $allowedShellCommands = ['/usr/bin/ls', '/usr/bin/git'];
// EventHandler only fires events you explicitly permit:
public array $allowedEvents = ['user.registered', 'cache.warm'];
ShellHandler executes through proc_open() with an argv array — never /bin/sh -c — so shell
metacharacters carry no attack surface. UrlHandler is SSRF-hardened (http/https only, private/
reserved IPs rejected, SSL verification forced on, redirects disabled). See Security
for the full handler-security model.
Envelope Signing¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
HMAC-SHA256 key used to sign queue envelopes. When |
|
|
|
When |
The signature is computed over the immutable identity fields only (job, payload, queue,
priority, maxRetries, name, identifier); the mutable attempts/schedule are excluded so
the signature survives a requeue. See Security for the key-resolution chain,
verification path, and threat model.
Idempotency¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
TTL (seconds) for idempotency keys stored by |
Idempotency is opt-in per job via JobBuilder::idempotencyKey(). See Retries.
Rate Limiting¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Maximum jobs processed per minute per queue. |
public array $queueRateLimits = [
'high_priority' => 100,
'default' => 50,
];
See Concurrency & Resilience for the rate limiter, circuit breaker and single-instance locking in detail.
Dead Letter Queue¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Queue name used by the opt-in |
Timeouts¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Maximum execution time per job in seconds ( |
|
|
|
Default per-attempt timeout applied to jobs that do not declare their own via |
The runtime enforces the per-job timeout if set, otherwise $defaultTimeout. When PHP pcntl is
available the timeout interrupts the running job (a SIGALRM handler that throws); otherwise it
degrades to a soft post-hoc check that cannot abort a runaway job.
Worker Behaviour¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Seconds the worker sleeps after an empty/rate-limited/circuit-open/error cycle before polling again. |
|
|
|
Reserved — not yet wired into the shipped worker; has no effect. The worker always fetches non-blocking (Beanstalk uses a hardcoded |
|
|
|
Reserved — not yet wired into the shipped worker; has no effect. (Beanstalk’s reserve timeout is hardcoded to 5s, not driven by this value.) |
|
|
|
Consecutive backend failures before the circuit opens. |
|
|
|
Seconds the circuit stays open before the worker retries the backend. |
Reaper / Visibility¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Visibility timeout (seconds) the Redis backend reaper uses to decide when an in-flight job belongs to a crashed worker and must be returned to the waiting list. |
|
|
|
Visibility timeout (seconds) the database backend reaper uses to return an |
|
|
|
Peek-lock timeout (seconds) requested when locking Service Bus messages. Must be ≥ the maximum job runtime, otherwise the broker may redeliver mid-execution. |
These are used by jobs:queue:reap. Beanstalk and Service Bus recover stalled work natively.
Retry / Backoff¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
One of |
|
|
|
Base delay (seconds) used to compute the first retry delay. |
|
|
|
Multiplier for the exponential strategy: |
|
|
|
Upper cap (seconds) on any computed delay. |
|
|
|
Add ±15% random jitter to the computed delay (exponential strategy). |
See Retries & Backoff for the full model.
Queues & Backends¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Comma list or array of available queue names. The first entry is the worker’s default when no queue is given. |
|
|
|
Default backend key (must exist in |
|
|
|
Single source of truth mapping a backend name to a |
public array $backends = [
'sync' => SyncBackend::class,
'database' => DatabaseBackend::class,
'redis' => RedisBackend::class,
'beanstalk' => BeanstalkBackend::class,
'serviceBus' => ServiceBusBackend::class,
];
public string $worker = 'database';
Backend-specific Settings¶
Database / history table¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Connection group and table for the database queue backend. |
|
|
|
Connection group used by the Jobs migrations ( |
|
|
|
Name of the table created by the Jobs history migration. |
Redis¶
Relies on ext-redis; host/port are taken from the CodeIgniter Redis configuration / environment.
Beanstalk¶
Property |
Type |
Default |
|---|---|---|
|
|
|
|
|
|
Azure Service Bus¶
Property |
Type |
Description |
|---|---|---|
|
|
Full queue endpoint, e.g. |
|
|
SAS key name. |
|
|
SAS key value — prefer |
Metrics¶
Property |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
FQCN of a |
Scheduled jobs: init()¶
Config\Jobs::init(Scheduler $scheduler) is called by jobs:cronjob:run before evaluating due
definitions. Register scheduled jobs on the fluent Scheduler here:
public function init(Scheduler $scheduler): void
{
$scheduler->define('command', 'app:report')
->named('daily-report')
->dailyAt('02:00')
->queue('reports')
->maxRetries(3);
$scheduler->define('closure', static fn () => cache()->clean())
->named('cache-clean')
->everyMinute();
}
Definitions that declare a queue() are enqueued; the rest run inline. The runner honours
enabled()/environments() and executes in topological order of dependsOn().
Minimal example¶
$cfg = config('Jobs');
$cfg->worker = 'redis';
$cfg->queues = 'default,reports';
$cfg->signingKey = env('JOBS_SIGNING_KEY');
$cfg->retryBackoffStrategy = 'exponential';
$cfg->retryBackoffBase = 3;
$cfg->retryBackoffMax = 180;
$cfg->deadLetterQueue = 'failed_jobs';