You are here

interface JobExecutorInterface in Apigee Edge 8

Job executor service definition.

Hierarchy

Expanded class hierarchy of JobExecutorInterface

All classes that implement JobExecutorInterface

2 files declare their use of JobExecutorInterface
DeveloperSyncController.php in src/Controller/DeveloperSyncController.php
JobQueueWorker.php in src/Plugin/QueueWorker/JobQueueWorker.php

File

src/JobExecutorInterface.php, line 28

Namespace

Drupal\apigee_edge
View source
interface JobExecutorInterface {

  /**
   * Saves a job.
   *
   * @param \Drupal\apigee_edge\Job\Job $job
   *   Job object.
   *
   * @throws \Exception
   */
  public function save(Job $job);

  /**
   * Loads a job from the database.
   *
   * @param string $id
   *   Job id.
   *
   * @return \Drupal\apigee_edge\Job\Job|null
   *   Loaded job object or null if it does not exit.
   */
  public function load(string $id) : ?Job;

  /**
   * Claims a job if one is available.
   *
   * @param null|string $tag
   *   Optional tag to filter with.
   *
   * @return \Drupal\apigee_edge\Job\Job|null
   *   Job object or null if there is no available.
   */
  public function select(?string $tag = NULL) : ?Job;

  /**
   * Executes a job synchronously.
   *
   * @param \Drupal\apigee_edge\Job\Job $job
   *   Job to run.
   * @param bool $update
   *   Whether to save the job into the database after it ran.
   *   Setting this to false means that it is the caller's responsibility to
   *   save the job into the database, else the job will be stuck in the
   *   "running" state.
   *
   * @throws \Exception
   */
  public function call(Job $job, bool $update = TRUE);

  /**
   * Executes a job asynchronously.
   *
   * This puts the job into the "apigee_edge_job" cron queue.
   *
   * @param \Drupal\apigee_edge\Job\Job $job
   *   The job to execute later.
   *
   * @throws \Exception
   */
  public function cast(Job $job);

  /**
   * Counts jobs in the queue.
   *
   * @param null|string $tag
   *   Optional tag to filter with.
   * @param array|null $statuses
   *   Optional statues to filter with.
   *
   * @return int
   *   Number of counted jobs.
   */
  public function countJobs(?string $tag = NULL, ?array $statuses = NULL) : int;

}

Members

Namesort descending Modifiers Type Description Overrides
JobExecutorInterface::call public function Executes a job synchronously. 1
JobExecutorInterface::cast public function Executes a job asynchronously. 1
JobExecutorInterface::countJobs public function Counts jobs in the queue. 1
JobExecutorInterface::load public function Loads a job from the database. 1
JobExecutorInterface::save public function Saves a job. 1
JobExecutorInterface::select public function Claims a job if one is available. 1