-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathQueueTask.php
More file actions
224 lines (197 loc) · 3.43 KB
/
Copy pathQueueTask.php
File metadata and controls
224 lines (197 loc) · 3.43 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
<?php
declare(strict_types=1);
namespace Bow\Queue;
use Bow\Support\Serializes;
use Throwable;
abstract class QueueTask
{
use Serializes;
/**
* Define the queue
*
* @var string
*/
protected string $queue = "default";
/**
* Define the delay
*
* @var int
*/
protected int $delay = 0;
/**
* Define the time of retry
*
* @var int
*/
protected int $retry = 30;
/**
* Define the priority
*
* @var int
*/
protected int $priority = 1;
/**
* Determine if the task can be deleted
*
* @var bool
*/
protected bool $delete = false;
/**
* Define the task id
*
* @return integer
*/
protected ?string $id = null;
/**
* Define the task attempts
*
* @var int
*/
protected int $attempts = 2;
/**
* Set the task ID
*
* @param string $id
* @return void
*/
public function setId(string $id)
{
$this->id = $id;
}
/**
* Get the task priority
*
* @return int
*/
final public function getPriority(): int
{
return $this->priority;
}
/**
* Get the task id
*
* @return string
*/
public function getId(): string
{
return $this->id;
}
/**
* Get the task attempts
*
* @return int
*/
public function getAttempts(): int
{
return $this->attempts;
}
/**
* Set the task attempts
*
* @param int $attempts
* @return void
*/
public function setAttempts(int $attempts): void
{
$this->attempts = $attempts;
}
/**
* Get the task retry
*
* @return int
*/
final public function getRetry(): int
{
return $this->retry;
}
/**
* Set the task retry
*
* @param int $retry
* @return void
*/
final public function setRetry(int $retry): void
{
$this->retry = $retry;
}
/**
* Get the task queue
*
* @return string
*/
final public function getQueue(): string
{
return $this->queue;
}
/**
* Set the task queue
*
* @param string $queue
* @return void
*/
final public function setQueue(string $queue): void
{
$this->queue = $queue;
}
/**
* Get the task delay
*
* @return int
*/
final public function getDelay(): int
{
return $this->delay;
}
/**
* Set the task delay
*
* @param int $delay
*/
final public function setDelay(int $delay): void
{
$this->delay = $delay;
}
/**
* Delete the task from queue.
*
* @return void
*/
public function deleteTask(): void
{
$this->delete = true;
}
/**
* Delete the task from queue.
*
* @return bool
*/
public function taskShouldBeDelete(): bool
{
return $this->delete;
}
/**
* Delete the task from queue.
*
* @return bool
*/
public function jobShouldBeDelete()
{
return $this->delete;
}
/**
* Get the task error
*
* @param Throwable $e
* @return void
*/
public function onException(Throwable $e)
{
//
}
/**
* Process the task
*
* @return void
*/
abstract public function process(): void;
}