Repository navigation
Expand file tree
/
Copy pathTaskInterface.php
More file actions
349 lines (248 loc) · 9.7 KB
/
Copy pathTaskInterface.php
File metadata and controls
349 lines (248 loc) · 9.7 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<?php
declare(strict_types=1);
namespace SchedulerBundle\Task;
use DateInterval;
use DateTimeImmutable;
use DateTimeZone;
use SchedulerBundle\Exception\InvalidArgumentException;
use SchedulerBundle\TaskBag\AccessLockBag;
use SchedulerBundle\TaskBag\NotificationTaskBag;
use Symfony\Component\Lock\Key;
/**
* @author Guillaume Loulier <contact@guillaumeloulier.fr>
*/
interface TaskInterface
{
/**
* @var string
*/
public const ENABLED = 'enabled';
/**
* @var string
*/
public const PAUSED = 'paused';
/**
* @var string
*/
public const DISABLED = 'disabled';
/**
* @var string
*/
public const READY_TO_EXECUTE = 'to_execute';
/**
* @var string
*/
public const UNDEFINED = 'undefined';
/**
* @var string
*/
public const CANCELLED = 'cancelled';
/**
* @var string[]
*/
public const ALLOWED_STATES = [
self::ENABLED,
self::PAUSED,
self::DISABLED,
self::READY_TO_EXECUTE,
self::UNDEFINED,
self::CANCELLED,
];
/**
* @var string
*/
public const SUCCEED = 'succeed';
/**
* @var string
*/
public const RUNNING = 'running';
/**
* @var string
*/
public const DONE = 'done';
/**
* @var string
*/
public const INCOMPLETE = 'incomplete';
/**
* @var string
*/
public const ERRORED = 'errored';
/**
* @var string
*/
public const TO_RETRY = 'to_retry';
/**
* @var string[]
*/
public const EXECUTION_STATES = [
self::SUCCEED,
self::RUNNING,
self::DONE,
self::INCOMPLETE,
self::ERRORED,
self::TO_RETRY,
];
/**
* Return the name of the task.
*/
public function getName(): string;
/**
* Define the name of the task.
*/
public function setName(string $name): self;
/**
* Set the date from which the task has been retrieved by the worker and started its execution.
*/
public function setArrivalTime(?DateTimeImmutable $dateTimeImmutable = null): self;
/**
* Return the date from which the task has been retrieved by the worker and started its execution.
*/
public function getArrivalTime(): ?DateTimeImmutable;
/**
* Set if the task must be executed in background, for more information {@see TaskInterface::mustRunInBackground()}.
*/
public function setBackground(bool $background): self;
/**
* Determine if the task must be executed in background, mostly used by {@see CommandTask} and {@see ShellTask}
*/
public function mustRunInBackground(): bool;
/**
* @param callable|array<object|string, string>|null $beforeSchedulingCallable
*/
public function beforeScheduling(callable|array|null $beforeSchedulingCallable = null): TaskInterface;
/**
* @return callable|array<object|string, string>|null
*/
public function getBeforeScheduling(): callable|array|null;
public function beforeSchedulingNotificationBag(?NotificationTaskBag $notificationTaskBag = null): TaskInterface;
public function getBeforeSchedulingNotificationBag(): ?NotificationTaskBag;
public function afterSchedulingNotificationBag(?NotificationTaskBag $notificationTaskBag = null): TaskInterface;
public function getAfterSchedulingNotificationBag(): ?NotificationTaskBag;
public function beforeExecutingNotificationBag(?NotificationTaskBag $notificationTaskBag = null): TaskInterface;
public function getBeforeExecutingNotificationBag(): ?NotificationTaskBag;
public function afterExecutingNotificationBag(?NotificationTaskBag $notificationTaskBag = null): TaskInterface;
public function getAfterExecutingNotificationBag(): ?NotificationTaskBag;
/**
* @param callable|array<object|string, mixed>|null $afterSchedulingCallable
*/
public function afterScheduling(callable|array|null $afterSchedulingCallable = null): TaskInterface;
/**
* @return callable|array<object|string, string>|null
*/
public function getAfterScheduling(): callable|array|null;
/**
* @param callable|array<object|string, mixed>|null $beforeExecutingCallable
*/
public function beforeExecuting(callable|array|null $beforeExecutingCallable = null): TaskInterface;
/**
* @return callable|array<object|string, string>|null
*/
public function getBeforeExecuting(): callable|array|null;
/**
* @param callable|array<object|string, mixed>|null $afterExecutingCallable
*/
public function afterExecuting(callable|array|null $afterExecutingCallable = null): TaskInterface;
/**
* @return callable|array<object|string, string>|null
*/
public function getAfterExecuting(): callable|array|null;
public function setDescription(?string $description = null): self;
public function getDescription(): ?string;
public function setExpression(string $expression): self;
public function getExpression(): string;
public function setExecutionAbsoluteDeadline(?DateInterval $dateInterval = null): self;
public function getExecutionAbsoluteDeadline(): ?DateInterval;
public function getExecutionComputationTime(): ?float;
public function setExecutionComputationTime(?float $executionComputationTime = null): self;
public function getExecutionDelay(): ?int;
public function setExecutionDelay(?int $executionDelay = null): self;
public function getExecutionMemoryUsage(): int;
public function setExecutionMemoryUsage(int $executionMemoryUsage): self;
public function getExecutionPeriod(): ?float;
public function setExecutionPeriod(?float $executionPeriod = null): self;
public function getExecutionRelativeDeadline(): ?DateInterval;
public function setExecutionRelativeDeadline(?DateInterval $dateInterval = null): self;
public function setExecutionStartDate(?string $executionStartDate = null): self;
/**
* Return the date from which the task is allowed to be executed / considered as "due".
*/
public function getExecutionStartDate(): ?DateTimeImmutable;
public function setExecutionEndDate(?string $executionEndDate = null): self;
/**
* Return the date until which the task is allowed to be executed / considered as "due".
*/
public function getExecutionEndDate(): ?DateTimeImmutable;
public function setExecutionStartTime(?DateTimeImmutable $dateTimeImmutable = null): self;
/**
* Return the date since the task started to being executed.
*/
public function getExecutionStartTime(): ?DateTimeImmutable;
public function setExecutionEndTime(?DateTimeImmutable $dateTimeImmutable = null): self;
/**
* Return the date since the task stopped to being executed.
*/
public function getExecutionEndTime(): ?DateTimeImmutable;
/**
* Allow to define an {@see AccessLockBag} which contains the {@see Key} used to create a lock linked to the current task.
*/
public function setAccessLockBag(?AccessLockBag $bag = null): void;
/**
* Return the {@see AccessLockBag} set using {@see TaskInterface::setAccessLockBag()}.
*
* It can be null IF the task is sent to the worker without being scheduled.
*/
public function getAccessLockBag(): ?AccessLockBag;
public function setLastExecution(?DateTimeImmutable $dateTimeImmutable = null): self;
public function getLastExecution(): ?DateTimeImmutable;
public function setMaxDuration(?float $maxDuration = null): self;
public function getMaxDuration(): ?float;
public function setMaxExecutions(?int $maxExecutions = null): TaskInterface;
public function getMaxExecutions(): ?int;
public function setMaxRetries(?int $maxRetries = null): TaskInterface;
public function getMaxRetries(): ?int;
public function getNice(): ?int;
public function setNice(?int $nice = null): self;
public function get(string $key, mixed $default = null): mixed;
public function getState(): string;
public function setState(string $state): self;
/**
* Return the execution state of the task or null when the task has been scheduled.
*/
public function getExecutionState(): ?string;
/**
* Define an execution state to the task (or null when scheduled).
*
* The execution state SHOULD be allowed regarding {@see TaskInterface::EXECUTION_STATES}.
*
* @throws InvalidArgumentException If the state is not allowed.
*/
public function setExecutionState(?string $executionState = null): self;
public function isOutput(): bool;
public function setOutput(bool $output): self;
public function storeOutput(bool $storeOutput = false): TaskInterface;
public function mustStoreOutput(): bool;
public function getPriority(): int;
public function setPriority(int $priority): self;
public function isQueued(): bool;
public function setQueued(bool $queued): self;
public function setScheduledAt(DateTimeImmutable $scheduledAt): self;
public function getScheduledAt(): ?DateTimeImmutable;
public function isSingleRun(): bool;
public function setSingleRun(bool $singleRun): self;
public function isDeleteAfterExecute(): bool;
public function setDeleteAfterExecute(bool $deleteAfterExecute): self;
/**
* @return array<int, string>
*/
public function getTags(): array;
/**
* @param array<int, string> $tags
*/
public function setTags(array $tags): self;
public function addTag(string $tag): self;
public function getTimezone(): ?DateTimeZone;
public function setTimezone(?DateTimeZone $dateTimeZone = null): self;
public function isTracked(): bool;
public function setTracked(bool $tracked): self;
}