-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJob.php
70 lines (61 loc) · 2.23 KB
/
Job.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace mle86\WQ\Job;
/**
* A Job is a representation of some task do to.
* It can be stored in a Work Queue with {@see WorkServerAdapter::storeJob()}.
*
* For your own Job classes,
* see the {@see AbstractJob} base class instead;
* it is easier to work with
* as it provides default implementations
* for the required methods.
*
* This interface does not specify how a Job should be executed
* or how the responsible method(s) should be named,
* if they are part of the Job implementation at all.
*/
interface Job
{
/**
* Whether this job can be retried later.
* The {@see WorkProcessor} helper class will check this if job execution has failed.
* If it returns true, the job will be stored in the Work Queue again
* to be re-executed after {@see jobRetryDelay()} seconds;
* if it returns false, the job will be buried for later inspection.
*/
public function jobCanRetry(): bool;
/**
* How many seconds the job should be delayed in the Work Queue
* before being re-tried.
* If {@see jobCanRetry()} is true,
* this must return a positive integer
* (or zero, if the job should be re-tried as soon as possible).
*/
public function jobRetryDelay(): ?int;
/**
* On the first try, this must return 1,
* on the first retry, this must return 2,
* and so on.
*/
public function jobTryIndex(): int;
/**
* Return `true` here if the instance should be considered expired.
*
* The {@see WorkServerAdapter} implementations don't care about this flag
* and will still return expired instances
* but the {@see WorkProcessor} class won't process them –
* they will be deleted as soon as they are encountered.
* Always return `false` here if your job class cannot expire.
*
* (Also see {@see JobResult::EXPIRED} which has the same effect as returning `true` here.)
*/
public function jobIsExpired(): bool;
/**
* @see https://www.php.net/manual/en/language.oop5.magic.php#object.serialize
*/
public function __serialize(): array;
/**
* @see https://www.php.net/manual/en/language.oop5.magic.php#object.unserialize
*/
public function __unserialize(array $data): void;
}