2014-02-11 08:00:24 -05:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2014-02-11 08:00:24 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2014-02-11 08:00:24 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCP\BackgroundJob;
|
2020-04-09 05:48:10 -04:00
|
|
|
|
2015-04-30 05:52:30 -04:00
|
|
|
use OCP\ILogger;
|
2014-02-11 08:00:24 -05:00
|
|
|
|
2015-04-16 11:00:08 -04:00
|
|
|
/**
|
2024-09-18 17:51:06 -04:00
|
|
|
* This interface represents a background job run with cron
|
2022-06-28 06:09:08 -04:00
|
|
|
*
|
|
|
|
|
* To implement a background job, you must extend either \OCP\BackgroundJob\Job,
|
|
|
|
|
* \OCP\BackgroundJob\TimedJob or \OCP\BackgroundJob\QueuedJob
|
2015-04-16 11:00:08 -04:00
|
|
|
*
|
|
|
|
|
* @since 7.0.0
|
|
|
|
|
*/
|
2014-02-11 08:00:24 -05:00
|
|
|
interface IJob {
|
2022-01-31 11:56:43 -05:00
|
|
|
/**
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public const TIME_INSENSITIVE = 0;
|
|
|
|
|
/**
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public const TIME_SENSITIVE = 1;
|
|
|
|
|
|
2014-02-11 08:00:24 -05:00
|
|
|
/**
|
2014-02-12 07:32:16 -05:00
|
|
|
* Run the background job with the registered argument
|
|
|
|
|
*
|
2020-07-03 04:46:51 -04:00
|
|
|
* @param IJobList $jobList The job list that manages the state of this job
|
2017-07-19 10:06:22 -04:00
|
|
|
* @param ILogger|null $logger
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 7.0.0
|
2024-09-18 17:51:06 -04:00
|
|
|
* @deprecated 25.0.0 Use start() instead. This method will be removed
|
2022-06-28 06:09:08 -04:00
|
|
|
* with the ILogger interface
|
2014-02-11 08:00:24 -05:00
|
|
|
*/
|
2024-03-28 11:13:19 -04:00
|
|
|
public function execute(IJobList $jobList, ?ILogger $logger = null);
|
2014-02-11 08:00:24 -05:00
|
|
|
|
2022-06-28 06:09:08 -04:00
|
|
|
/**
|
|
|
|
|
* Start the background job with the registered argument
|
|
|
|
|
*
|
|
|
|
|
* This methods will take care of running the background job, of initializing
|
|
|
|
|
* the state and cleaning up the job list after running the job.
|
|
|
|
|
*
|
|
|
|
|
* For common background job scenario, you will want to use TimedJob or QueuedJob
|
|
|
|
|
* instead of overwritting this method.
|
|
|
|
|
*
|
|
|
|
|
* @param IJobList $jobList The job list that manages the state of this job
|
|
|
|
|
* @since 25.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function start(IJobList $jobList): void;
|
|
|
|
|
|
2015-12-18 08:16:32 -05:00
|
|
|
/**
|
|
|
|
|
* @since 7.0.0
|
|
|
|
|
*/
|
2020-07-06 04:13:23 -04:00
|
|
|
public function setId(int $id);
|
2015-12-18 08:16:32 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 7.0.0
|
|
|
|
|
*/
|
2020-07-06 04:13:23 -04:00
|
|
|
public function setLastRun(int $lastRun);
|
2015-12-18 08:16:32 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param mixed $argument
|
|
|
|
|
* @since 7.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function setArgument($argument);
|
|
|
|
|
|
2014-02-12 07:32:16 -05:00
|
|
|
/**
|
|
|
|
|
* Get the id of the background job
|
|
|
|
|
* This id is determined by the job list when a job is added to the list
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 7.0.0
|
2014-02-12 07:32:16 -05:00
|
|
|
*/
|
2014-02-11 08:00:24 -05:00
|
|
|
public function getId();
|
|
|
|
|
|
2014-02-12 07:32:16 -05:00
|
|
|
/**
|
|
|
|
|
* Get the last time this job was run as unix timestamp
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 7.0.0
|
2014-02-12 07:32:16 -05:00
|
|
|
*/
|
2014-02-11 08:00:24 -05:00
|
|
|
public function getLastRun();
|
|
|
|
|
|
2014-02-12 07:32:16 -05:00
|
|
|
/**
|
|
|
|
|
* Get the argument associated with the background job
|
|
|
|
|
* This is the argument that will be passed to the background job
|
|
|
|
|
*
|
|
|
|
|
* @return mixed
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 7.0.0
|
2014-02-12 07:32:16 -05:00
|
|
|
*/
|
2014-02-11 08:00:24 -05:00
|
|
|
public function getArgument();
|
|
|
|
|
}
|