-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathTransportInterface.php
77 lines (65 loc) · 2.49 KB
/
TransportInterface.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
71
72
73
74
75
76
77
<?php
declare(strict_types=1);
namespace SchedulerBundle\Transport;
use SchedulerBundle\Exception\InvalidArgumentException;
use SchedulerBundle\Exception\LogicException;
use SchedulerBundle\Task\LazyTask;
use SchedulerBundle\Task\LazyTaskList;
use SchedulerBundle\Task\TaskInterface;
use SchedulerBundle\Task\TaskListInterface;
use SchedulerBundle\Transport\Configuration\ConfigurationInterface;
use Throwable;
/**
* @author Guillaume Loulier <[email protected]>
*/
interface TransportInterface
{
/**
* Return a stored task, if the task does not exist, an {@see InvalidArgumentException} MUST be thrown.
*
* Can return a {@see LazyTask} if @param bool $lazy is used.
*/
public function get(string $name, bool $lazy = false): TaskInterface|LazyTask;
/**
* If @param bool $lazy is used, a {@see LazyTaskList} MUST be returned.
*
* @return TaskListInterface<int|string, TaskInterface>|LazyTaskList<int|string, TaskInterface>
*
* @throws Throwable
*/
public function list(bool $lazy = false): TaskListInterface|LazyTaskList;
/**
* Add the task into the transport list, if the task name already exist, the new task is not added.
*/
public function create(TaskInterface $task): void;
/**
* Update an existing task using the $updatedTask payload, if the task does not exist, it should be created.
*
* The recommended approach is to call {@see TransportInterface::get()} first to retrieve the task.
*/
public function update(string $name, TaskInterface $updatedTask): void;
/**
* Delete a task, if this task does not exist, an {@see InvalidArgumentException} COULD be thrown.
*/
public function delete(string $name): void;
/**
* Allow to pause a task, if the task does not exist, a {@see InvalidArgumentException} MUST be thrown.
*
* If the task exist but it's already paused, a {@see LogicException} must be thrown.
*/
public function pause(string $name): void;
/**
* Allow to resume a task, if the task does not exist, a {@see InvalidArgumentException} MUST be thrown.
*
* If the task exist but it's already resumed, a {@see LogicException} must be thrown.
*/
public function resume(string $name): void;
/**
* Remove all the tasks from the current transport.
*/
public function clear(): void;
/**
* {@see ConfigurationInterface::toArray()}
*/
public function getConfiguration(): ConfigurationInterface;
}