Download the PHP package zotlo/phalcon-queue without Composer
On this page you can find all versions of the php package zotlo/phalcon-queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zotlo/phalcon-queue
More information about zotlo/phalcon-queue
Files in zotlo/phalcon-queue
Package phalcon-queue
Short Description Dashboard and code-driven configuration for Phalcon 5 queues.
License MIT
Informations about the package phalcon-queue
PQueue - Queue Worker for Phalcon
PQueue provide a very simple way to run workers to consume queues (consumers) in PHP. The library have been developed to be easily extended to work with different queue servers and open to manage any kind of job.
Current implementations:
- MySQL queue adapter.
- Redis queue adapter.
- SQLite queue adapter.
and more adapter planning development
Worker
The lib has a worker class that run and infinite loop (can be stopped with some conditions) and manage all the stages to process jobs:
- Get next job.
- Execute job.
- Job success then do.
- Job failed then do.
- Execution error then do.
- No jobs then do.
- Stop worker process pid.
The loop can be stopped under control using the following methods:
- Stop Job: The job handler allow to define a STOP job.
- Max Iterations: It can be specified when the object is declared.
Each worker has one queue source and manage one type of jobs. Many workers can be working concurrently using the same queue source.
Graceful Exit
The worker is also capable for handling some posix signals, viz. SIGINT
and SIGTERM
so
that it exits gracefully (waits for the current queue job to complete) when someone tries to
manually stop it (usually with a C-c
keystroke in a shell).
Queue
The lib provide an interface which allow to implement a queue connection for different queue servers. Currently the lib provide following implementations:
- MySQL queue adapter.
- Redis queue adapter.
- SQLite queue adapter.
The queue interface manage all related with the queue system and abstract the job about that.
It require the queue system client:
- MySQL : Phalcon\Db\Adapter\Pdo
- Redis : Predis\Client
- SQLite : ext-pdo
And was well the source queue name. The consumer will need additional queues to manage the process:
- Processing Queue: It will store the item popped from source queue while it is being processed.
- Failed Queue: All Jobs that fail (according the Job definition) will be add in this queue.
Jobs
The job interface is used to manage the job received in the queue. It must manage the domain business logic and define the STOP job.
The job is abstracted form the queue system, so the same job definition is able to work with different queues interfaces. The job always receive the message body from the queue.
If you have different job types ( send mail, crop images, etc. ) and you use one queue, you can define isMyJob. If job is not expected type, you can send back job to queue.
Install
Require the package in your composer json file:
Configure
Register the ServiceProvider in cli.php file.
Define Supervisors in Phalcon config. It is possible to define more than one Queue.
Set Supervisor Config
You must start each queue you define in supervisor.
Usage
The first step is to define and implement the Job to be managed.
You can call the dispatch function anywhere you want.
You can set queue.
You can set delay.
You can dispatch job batch.
Async Job
You can also define tasks that you want to run asynchronously without creating any classes.
Also, You can get the status of any job you start at any time. Use await.
IMPORTANT: You can't do that
All versions of phalcon-queue with dependencies
ext-pdo Version *
ext-redis Version *
ext-pcntl Version *
ext-phalcon Version 5.*
symfony/process Version ^7.1
symfony/console Version ^7.1
polatdev/closure Version ^1.0