Codeigniter Jobs Documentation
Welcome to the Daycry Jobs documentation. This site centralizes guides, architecture notes and usage examples for the advanced job scheduling & queue processing package for CodeIgniter 4.
Quick Overview
Unified Job API: command, shell, closure, event, URL handlers.
Schedulers & Queues: cron-like scheduling plus multiple queue backends (Redis, Database, Beanstalk, Azure Service Bus, Sync).
Reliable backends (v1.1+): ServiceBus peek-lock, Redis reliable-queue pattern (RPOPLPUSH + processing list + reaper), optional BRPOPLPUSH/blocking fetch, robust optimistic locking on the Database backend.
Hardened handlers (v1.1+): UrlJob with scheme whitelist + multi-IP DNS validation (IPv4 + IPv6); ShellJob with realpath-based whitelist.
NDJSON file logging (v1.1+): append-only writes with deterministic pruning; transparent read of legacy JSON-array files.
Fail-loud DLQ (v1.0.3+):
DeadLetterQueue::store()returns bool;RequeueHelperattempts the DLQ before clearing the origin and emitsjobs_dlq_failedif anything goes wrong.Heartbeat singleInstance lock (v1.2+): long-running jobs no longer lose their lock prematurely.
Worker maintenance (v1.2+): DB ping/reconnect every 100 iterations, in-memory metrics reset every 1 000 iterations.
Centralized Queue Management:
QueueManagersingleton for backend access and caching.Schema Versioning:
PayloadSerializerwith migration support for evolving payload structures.Transparent Metrics:
InstrumentedQueueDecoratorwraps any queue with 7 automatic metrics.Retries & Backoff: fixed, exponential, jitter policies with normalized attempt semantics.
Structured Logging & Masking: configurable drivers (file/database) with sensitive key masking; pattern-based detection of JWT/Bearer/known API-key prefixes.
Callbacks & Chaining: post-execution jobs with inheritance and filter conditions.
Metrics Layer: pluggable counters/histograms via
MetricsCollectorInterface.v2 opt-in API (v2.0-alpha):
JobDefinitionimmutable +QueueBackendlease-based contract — see V2 Migration.
Getting Started
Install the package:
composer require daycry/jobs
Publish and run migrations:
php spark jobs:publish php spark migrate -all
Configure queues & worker in
app/Config/Jobs.php.Run the cron worker:
php spark jobs:cronjob:run
Run a queue worker:
php spark jobs:queue:run
Key Sections
Topic |
Description |
|---|---|
Configuration |
All tunables (queues, retries, logging, timeouts) |
Architecture |
Internal components and lifecycle flow |
Queues |
Backend capabilities, QueueManager, serialization |
Queue Simplification |
Migration guide for refactored queue subsystem |
Metrics |
Instrumentation, InstrumentedQueueDecorator, custom collectors |
Logging |
Structured log emission and masking |
Retries |
Policies and backoff semantics |
Attempts |
Attempt counting model |
CLI Commands |
Operational control & maintenance |
Testing |
Test organization, running tests, writing tests |
Use the navigation to dive deeper into each area.
Contributing
Contributions and feedback are welcome. Please open issues or PRs at the GitHub repository.
License
MIT License. See the full text in the repository.