Download the PHP package fyre/queue without Composer
On this page you can find all versions of the php package fyre/queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package queue
FyreQueue
FyreQueue is a free, open-source queue library for PHP.
Table Of Contents
- Installation
- Basic Usage
- Methods
- Queues
- Redis
- Workers
- Messages
- Commands
- Stats
- Worker
Installation
Using Composer
In PHP:
Basic Usage
Default configuration options will be resolved from the "Queue" key in the Config.
Autoloading
It is recommended to bind the QueueManager to the Container as a singleton.
Any dependencies will be injected automatically when loading from the Container.
Methods
Build
Build a Queue.
$options
is an array containing configuration options.
Container.
Clear
Clear all instances and configs.
Get Config
Set a Queue config.
$key
is a string representing the Queue key.
Alternatively, if the $key
argument is omitted an array containing all configurations will be returned.
Has Config
Determine whether a Queue config exists.
$key
is a string representing the Queue key, and will default toQueueManager::DEFAULT
.
Is Loaded
Determine whether a Queue instance is loaded.
$key
is a string representing the Queue key, and will default toQueueManager::DEFAULT
.
Push
Push a job to a Queue.
$className
is a string representing the job class.$arguments
is an array containing arguments that will be passed to the job.$options
is an array containing options for the Message.config
is a string representing the configuration key, and will default toQueueManager::DEFAULT
.queue
is a string representing the queue name, and will default toQueueManager::DEFAULT
.method
is a string representing the class method, and will default to "run".delay
is a number representing the number of seconds before the job should run, and will default to 0.expires
is a number representing the number of seconds after which the job will expire, and will default to 0.retry
is a boolean indicating whether the job should be retried if it fails, and will default to true.maxRetries
is a number indicating the maximum number of times the job should be retried, and will default to 5.unique
is a boolean indicating whether the job should be unique, and will default to false.
Job dependencies will be resolved automatically from the Container.
Set Config
Set the Queue config.
$key
is a string representing the Queue key.$options
is an array containing configuration options.
Unload
Unload a Queue.
$key
is a string representing the Queue key, and will default toQueueManager::DEFAULT
.
Use
Load a shared Queue instance.
$key
is a string representing the Queue key, and will default to "default".
Container.
Queues
You can load a specific queue by specifying the className
option of the $options
variable above.
Custom queues can be created by extending \Fyre\Queue\Queue
, ensuring all below methods are implemented.
Clear
Clear all items from the queue.
$queueName
is a string representing the queue name, and will default toQueueManager::DEFAULT
.
Complete
Mark a job as completed.
$message
is a Message.
Fail
Mark a job as failed.
$message
is a Message.
Pop
Pop the last item off the queue.
$queueName
is a string representing the queue name.
Push
Push a job onto the queue.
$message
is a Message.
Queues
Get all the active queues.
Reset
Reset the queue statistics.
$queueName
is a string representing the queue name, and will default toQueueManager::DEFAULT
.
Stats
Get the statistics for a queue.
$queueName
is a string representing the queue name, and will default toQueueManager::DEFAULT
.
Redis
The Redis queue can be loaded using custom configuration.
$options
is an array containing configuration options.className
must be set to\Fyre\Queue\Handlers\RedisQueue
.host
is a string representing the Redis host, and will default to "127.0.0.1".password
is a string representing the Redis passwordport
is a number indicating the Redis port, and will default to 6379.database
is a string representing the Redis database.timeout
is a number indicating the connection timeout.persist
is a boolean indicating whether to use a persistent connection, and will default to true.tls
is a boolean indicating whether to use a tls connection, and will default to true.ssl
is an array containing SSL options.key
is a string representing the path to the key file.cert
is a string representing the path to the certificate file.ca
is a string representing the path to the certificate authority file.
Workers
Workers are long running tasks that will consume and execute jobs from the queue.
$container
is a Container.$queueManager
is a QueueManager.$eventManager
is an EventManager.$options
is an array containing configuration options.config
is a string representing the configuration key, and will default toQueueManager::DEFAULT
.queue
is a string representing the queue name, and will default toQueueManager::DEFAULT
.maxJobs
is a number representing the maximum number of jobs to execute, and will default to 0.maxRuntime
is a number representing the maximum number of seconds the worker should run, and will default to 0.rest
is a number representing the number of microseconds to rest after processing a job, and will default to 10000.sleep
is a number representing the number of microseconds to sleep if no jobs are in the queue, and will default to 100000.
Run
Run the worker.
Messages
Messages are used internally to pass data between the Worker.
$options
is an array containing options for the message.className
is a string representing the job class.arguments
is an array containing arguments that will be passed to the job.config
is a string representing the configuration key, and will default toQueueManager::DEFAULT
.queue
is a string representing the queue name, and will default toQueueManager::DEFAULT
.method
is a string representing the class method, and will default to "run".delay
is a number representing the number of seconds before the job should run, and will default to 0.expires
is a number representing the number of seconds after which the job will expire, and will default to 0.retry
is a boolean indicating whether the job should be retried if it fails, and will default to true.maxRetries
is a number indicating the maximum number of times the job should be retried, and will default to 5.unique
is a boolean indicating whether the job should be unique, and will default to false.
Get After
Get the timestamp when the message can be sent.
Get Config
Get the message config.
Get Hash
Get the message hash.
Get Queue
Get the message queue.
Is Expired
Determine whether the message has expired.
Is Ready
Determine whether the message is ready.
Is Unique
Determine whether the message is unique.
Is Valid
Determine whether the message is valid.
Should Retry
Determine whether the message should be retried.
Commands
Stats
Display stats for the queue.
--config
is a the configuration key, and will default toQueueManager::DEFAULT
.--queue
is a the queue name, and will default toQueueManager::DEFAULT
.
Worker
Start a background queue worker.
--config
is a the configuration key, and will default toQueueManager::DEFAULT
.--queue
is a the queue name, and will default toQueueManager::DEFAULT
.--max-jobs
is the maximum number of jobs to execute, and will default to 0.--max-runtime
is the maximum number of seconds the worker should run, and will default to 0.
All versions of queue with dependencies
fyre/config Version ^4.0
fyre/container Version ^1.0
fyre/event Version ^4.0