Download the PHP package ride/lib-queue without Composer
On this page you can find all versions of the php package ride/lib-queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package lib-queue
Ride: Queue Library
Queue abstraction library of the PHP Ride framework.
Use a queue system for time-consuming tasks.
What's In This Library
QueueJob
The QueueJob interface is for you to implement. It holds the logic to run your task.
Your job implementation will probably need data to work with. Instead of attaching initialized objects to your job, you should attach references to the needed data, like id's. It will make your job smaller to store since id's are easier to serialize then object instances.
When your job is invoked, you should lookup your data, using the references, in the current state instead of the state when the job was queued.
QueueManager
The QueueManager interface is to be implemented for the underlying queue system. This is the facade to the queue system. You can check the status of the system, a queue or a job. It's also used to queue jobs and to update their status.
The QueueJob interface receives the QueueManager when it's invoked. The queue manager should be extended so it can be used by queue jobs to lookup their references.
QueueJobStatus
When you ask information about queue jobs, the QueueManager will return QueueJobStatus instances. This interface is also to be implemented by the underlying queue system.
QueueDispatcher
A QueueJob holds the queue it is in. When you create a job, you might not know about the available queues or their availability. You can use a QueueDispatcher to queue the job. This dispatcher's goal is to select the proper queue for the job and perform the queueing process.
There are 2 dispatchers provided by the library.
SingleQueueDispatcher
The SingleQueueDispatcher is a very simple dispatcher. It's used when you have only one static queue.
RoundRobinQueueDispatcher
The RoundRobinQueueDispatcher is initialized with a number of queues. When this dispatcher queues a job, it will push it to the queue with the least amount of jobs pending.
QueueWorker
A QueueWorker is used to grab jobs from the queue, and invoke them. This work process is most likely a command or daemon which runs in the background. You will need a worker for each queue.
A generic implementation is provided with the GenericQueueWorker class.
Code Sample
Check this code sample to see some possibilities of this library:
Related Modules
You can check the following related modules to this library:
- ride/app-queue-beanstalkd
- ride/app-queue-orm
- ride/cli-queue
- ride/lib-common
- ride/lib-log
- ride/lib-queue-beanstalkd
- ride/wba-queue
- ride/wra-queue
Installation
You can use Composer to install this library.