Worker options
Zeridion\Flare\Worker\WorkerOptions configures a worker. Construct it
directly with named arguments, or build it from the environment with
WorkerOptions::fromEnv().
use Zeridion\Flare\Worker\WorkerOptions;
$options = new WorkerOptions(
apiKey: 'zf_live_sk_...',
baseUrl: 'https://api.zeridion.com',
queues: ['default', 'email'],
pollIntervalSeconds: 2.0,
);
$worker = new FlareWorker($options);
From the environment
$options = WorkerOptions::fromEnv();
reads these environment variables:
| Variable | Maps to | Default |
|---|---|---|
FLARE_API_KEY | apiKey | — (falls back to the env var when apiKey is null) |
FLARE_BASE_URL | baseUrl | https://api.zeridion.com |
FLARE_QUEUES | queues (comma-separated) | default |
FLARE_POLL_INTERVAL | pollIntervalSeconds | 2.0 |
Pass overrides as the first argument to layer explicit values on top:
$options = WorkerOptions::fromEnv(['concurrency' => 5]);
All options
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | ?string | null | API key. Falls back to FLARE_API_KEY. |
baseUrl | string | https://api.zeridion.com | API base URL. |
queues | string[] | ['default'] | Queues this worker serves. |
concurrency | int | 1 | In-flight job cap. One job per process — values above 1 log a warning. |
pollIntervalSeconds | float | 2.0 | Idle delay between empty polls. |
defaultTimeoutSeconds | int | 1800 | Fallback per-job timeout when a job omits one. |
defaultMaxAttempts | int | 3 | Fallback maximum attempts. |
pollRequestTimeoutSeconds | float | 35.0 | Read timeout for the long-poll. Kept above 30 s so it never races the long-poll. |
shutdownGraceSeconds | float | 30.0 | Time allowed to finish the in-flight job on shutdown. |
maxJobsPerProcess | int | 0 | Exit after this many jobs so a supervisor restarts a fresh process (0 = never). |
maxMemoryMb | int | 0 | Exit when memory exceeds this many MiB (0 = never). |
logger | Logger | silent | Where the worker writes structured logs. Defaults to a silent sink. |
Logging
By default the worker logs nothing. Supply a logger to see lifecycle and per-job events:
use Zeridion\Flare\Worker\StderrLogger;
$options = new WorkerOptions(apiKey: '...', logger: new StderrLogger('info'));
StderrLogger writes one line per event to standard error. To route worker
logs through your own logging stack, implement
Zeridion\Flare\Worker\Logger (a small log(level, message, context)
contract that mirrors the standard log levels).
Process recycling
Long-lived PHP processes can accumulate memory. Set maxJobsPerProcess or
maxMemoryMb so the worker exits cleanly after a threshold; a process
supervisor then starts a fresh one.