Class AbstractQueueManager
Abstract Queue Manager
The queue manager is used to load queued items and batch-process them.
Loading queued items
If a "queue_id" is specified, only the item for this specific queue will be loaded.
Otherwise, all unprocessed queue items will be processed.
Type of queue items
The type of queue items can be set in extended concrete class with the
queue_item_proto()
method. This method should return a QueueItemInterface instance.
Callbacks
There are 4 available callback methods that can be set:
item_callback
- Called after an item has been processed. - Arguments: QueueModelInterface $item
item_success_callback
item_failure_callback
processed_callback
- Called when the entire queue has been processed - Arguments: array $success
, array $failures
-
Charcoal\Queue\AbstractQueueManager
implements
Charcoal\Queue\QueueManagerInterface,
Psr\Log\LoggerAwareInterface
uses
Psr\Log\LoggerAwareTrait (not available)
Methods summary
public
|
#
__construct( array $data = [] )
Construct new queue manager.
Construct new queue manager.
Parameters
- $data
- Dependencies and settings.
|
protected
Charcoal\Queue\QueueItemInterface
|
#
setQueueItemFactory( Charcoal\Factory\FactoryInterface $factory )
Parameters
- $factory
- The factory used to create queue items.
Returns
|
protected
Charcoal\Factory\FactoryInterface
|
|
public
Charcoal\Queue\AbstractQueueManager
|
#
setData( array $data )
Set the manager's data.
Parameters
- $data
- The queue data to set.
Returns
|
public
Charcoal\Queue\AbstractQueueManager
|
#
setQueueId( mixed $id )
Set the queue's ID.
Parameters
- $id
- The unique queue identifier.
Returns
Implementation of
|
public
mixed
|
#
queueId( )
Get the queue's ID.
Returns
mixed
Implementation of
|
public
Charcoal\Queue\QueueManagerInterface
|
#
setItemCallback( callable $callback )
Set the callback routine when an item is processed.
Set the callback routine when an item is processed.
Parameters
- $callback
- A item callback routine.
Returns
|
public
Charcoal\Queue\QueueManagerInterface
|
#
setItemSuccessCallback( callable $callback )
Set the callback routine when the item is resolved.
Set the callback routine when the item is resolved.
Parameters
- $callback
- A item callback routine.
Returns
Implementation of
|
public
Charcoal\Queue\QueueManagerInterface
|
#
setItemFailureCallback( callable $callback )
Set the callback routine when the item is rejected.
Set the callback routine when the item is rejected.
Parameters
- $callback
- A item callback routine.
Returns
Implementation of
|
public
Charcoal\Queue\QueueManagerInterface
|
#
setProcessedCallback( callable $callback )
Set the callback routine when the queue is processed.
Set the callback routine when the queue is processed.
Parameters
- $callback
- A queue callback routine.
Returns
Implementation of
|
public
boolean
|
#
processQueue( callable $callback = null )
Process the items of the queue.
Process the items of the queue.
If no callback is passed and a self::$processedCallback is set, the latter is used.
Parameters
- $callback
An optional alternative callback routine executed
after all queue items are processed.
Returns
boolean Success / Failure
Implementation of
|
public
Collection
|
#
loadQueueItems( )
Retrieve the items of the current queue.
Retrieve the items of the current queue.
Returns
Collection
Implementation of
|
abstract public
Charcoal\Queue\QueueItemInterface
|
#
queueItemProto( )
Retrieve the queue item's model.
Retrieve the queue item's model.
Returns
Implementation of
|