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-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
|
2024-09-18 18:37:55 -04:00
|
|
|
* @since 25.0.0 deprecated `execute()` method in favor of `start()`
|
|
|
|
|
* @since 33.0.0 removed deprecated `execute()` method
|
2015-04-16 11:00:08 -04:00
|
|
|
*/
|
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;
|
|
|
|
|
|
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
|
2024-09-18 18:37:55 -04:00
|
|
|
* instead of overwriting this method.
|
2022-06-28 06:09:08 -04:00
|
|
|
*
|
|
|
|
|
* @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
|
2025-11-24 12:11:53 -05:00
|
|
|
* @since 33.0.0 Parameter $id changed from int to string
|
2015-12-18 08:16:32 -05:00
|
|
|
*/
|
2025-11-24 12:11:53 -05:00
|
|
|
public function setId(string $id): void;
|
2015-12-18 08:16:32 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 7.0.0
|
|
|
|
|
*/
|
2025-11-24 12:11:53 -05:00
|
|
|
public function setLastRun(int $lastRun): void;
|
2015-12-18 08:16:32 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param mixed $argument
|
|
|
|
|
* @since 7.0.0
|
|
|
|
|
*/
|
2025-11-24 12:11:53 -05:00
|
|
|
public function setArgument(mixed $argument): void;
|
2015-12-18 08:16:32 -05:00
|
|
|
|
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
|
|
|
|
|
*
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 7.0.0
|
2025-11-24 12:11:53 -05:00
|
|
|
* @since 33.0.0 The return type changed from int to string
|
2014-02-12 07:32:16 -05:00
|
|
|
*/
|
2025-11-24 12:11:53 -05:00
|
|
|
public function getId(): string;
|
2014-02-11 08:00:24 -05:00
|
|
|
|
2014-02-12 07:32:16 -05:00
|
|
|
/**
|
|
|
|
|
* Get the last time this job was run as unix timestamp
|
|
|
|
|
*
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 7.0.0
|
2014-02-12 07:32:16 -05:00
|
|
|
*/
|
2025-11-24 12:11:53 -05:00
|
|
|
public function getLastRun(): int;
|
2014-02-11 08:00:24 -05:00
|
|
|
|
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
|
|
|
|
|
*
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 7.0.0
|
2014-02-12 07:32:16 -05:00
|
|
|
*/
|
2025-11-24 12:11:53 -05:00
|
|
|
public function getArgument(): mixed;
|
2014-02-11 08:00:24 -05:00
|
|
|
}
|