Download the PHP package n0nag0n/simple-job-queue without Composer
On this page you can find all versions of the php package n0nag0n/simple-job-queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download n0nag0n/simple-job-queue
More information about n0nag0n/simple-job-queue
Files in n0nag0n/simple-job-queue
Package simple-job-queue
Short Description A simple library for interfacing with other job queue providers that gives you plenty of flexibility. Supports MySQL, PostgreSQL, SQLite, and Beanstalkd.
License MIT
Informations about the package simple-job-queue
Simple PHP Job Queue
I wanted/needed a simple job queue that could be used on a database, but also used with other adapters like beanstalkd/redis/etc if needed. Didn't really see a good option for a standalone job queue for a database.
Install
Requirements: PHP 7.4 or higher.
Note on Beanstalkd: The
pda/pheanstalkpackage is only needed if you use the Beanstalkd adapter. It is listed undersuggestincomposer.json(not a hard requirement) so pure database users are not forced to install it.
Usage
In order for this to work, you need a way to add jobs to the queue and a way to process the jobs (a worker). Below are examples of how to add a job to the queue and how to process the job.
Adding a new job
MySQL
PostgreSQL
SQLite3
Beanstalkd
Running a worker
See example_worker.php for file or see below:
Handling long processes
Supervisord is going to be your jam. Look up the many, many articles on how to implement this.
Configurable options
Several behaviors can be tuned via the $options array passed to the constructor (or setOptions()):
stale_timeout(int, seconds): How long to wait before a reserved job is considered "stale" and can be re-claimed by another worker (DB backends only). Default:300(5 minutes). This default preserves the historical behavior exactly.
Example:
Additional methods (additive, non-breaking)
New methods have been added that do not change any existing behavior:
releaseJob($job)— Un-reserves a job that was previously obtained viagetNextJobAndReserve(), making it available again immediately (useful if processing was abandoned).getReadyCount(?string $pipeline = null): intgetBuriedCount(?string $pipeline = null): int
These work for all supported backends. Pass a pipeline name to query a specific one, or omit to use the currently selected pipeline.
See the source or tests for usage examples. All new functionality follows the same "select/watch pipeline + connection" contract as the rest of the library.
Testing
PHPUnit Tests with sqlite3 examples for the time being.
All versions of simple-job-queue with dependencies
ext-pdo Version *