Commit | Line | Data |
---|---|---|
8e16faaf C |
1 | <?php |
2 | ||
3 | namespace wcf\system\background\job; | |
4 | ||
8e16faaf | 5 | /** |
b534da2e C |
6 | * This background job is only queued once |
7 | * and is requeued when it has more work to do. | |
8 | * | |
8e16faaf C |
9 | * @author Olaf Braun |
10 | * @copyright 2001-2024 WoltLab GmbH | |
11 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
12 | * @since 6.1 | |
13 | */ | |
14 | abstract class AbstractUniqueBackgroundJob extends AbstractBackgroundJob | |
15 | { | |
16 | /** | |
17 | * @inheritDoc | |
18 | */ | |
ccd884a5 | 19 | final public const MAX_FAILURES = 0; |
8e16faaf C |
20 | |
21 | /** | |
22 | * Returns a unique identifier for this job. | |
8e16faaf C |
23 | */ |
24 | public function identifier(): string | |
25 | { | |
26 | return static::class; | |
27 | } | |
28 | ||
8e16faaf | 29 | /** |
86543b0c C |
30 | * Returns a new instance of this job to be queued again. |
31 | * This will reset the fail counter. | |
8e16faaf | 32 | */ |
2affbaea | 33 | public function newInstance(): static |
86543b0c C |
34 | { |
35 | return new static(); | |
36 | } | |
8e16faaf C |
37 | |
38 | /** | |
39 | * Returns whether this job should be queued again because it has more to do. | |
40 | * | |
41 | * @return bool | |
42 | */ | |
86543b0c | 43 | abstract public function queueAgain(): bool; |
8e16faaf C |
44 | |
45 | #[\Override] | |
46 | final public function onFinalFailure() | |
47 | { | |
86543b0c C |
48 | // onFailure() and onFinalFailure() are called at the same time. |
49 | // Do your stuff in onFailure(). | |
50 | } | |
51 | ||
52 | #[\Override] | |
53 | public function retryAfter() | |
54 | { | |
55 | // change the default value to 60 seconds | |
56 | return 60; | |
8e16faaf C |
57 | } |
58 | } |