class JobQueueWorker in Apigee Edge 8
Worker class for processing a queue item.
Plugin annotation
@QueueWorker(
id = "apigee_edge_job",
title = "Apigee Edge job runner",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\apigee_edge\Plugin\QueueWorker\JobQueueWorker implements ContainerFactoryPluginInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of JobQueueWorker
File
- src/
Plugin/ QueueWorker/ JobQueueWorker.php, line 37
Namespace
Drupal\apigee_edge\Plugin\QueueWorkerView source
class JobQueueWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {
/**
* The job executor service.
*
* @var \Drupal\apigee_edge\JobExecutor
*/
protected $executor;
/**
* The queue object.
*
* @var \Drupal\Core\Queue\QueueInterface
*/
protected $queue;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, JobExecutorInterface $executor, QueueFactory $queue_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->executor = $executor;
$this->queue = $queue_factory
->get('apigee_edge_job');
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
/** @var \Drupal\apigee_edge\JobExecutor $executor */
$executor = $container
->get('apigee_edge.job_executor');
/** @var \Drupal\Core\Queue\QueueFactory $queueFactory */
$queue_factory = $container
->get('queue');
return new static($configuration, $plugin_id, $plugin_definition, $executor, $queue_factory);
}
/**
* {@inheritdoc}
*/
public function processItem($data) {
$job = $this->executor
->select($data['tag']);
if (!$job || $job
->getStatus() !== Job::SELECTED) {
return;
}
$this->executor
->call($job);
$this->queue
->createItem([
'tag' => $data['tag'],
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JobQueueWorker:: |
protected | property | The job executor service. | |
JobQueueWorker:: |
protected | property | The queue object. | |
JobQueueWorker:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
JobQueueWorker:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
JobQueueWorker:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. |