Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | /** |
| 3 | * Pop PHP Framework (https://www.popphp.org/) |
| 4 | * |
| 5 | * @link https://github.com/popphp/popphp-framework |
| 6 | * @author Nick Sagona, III <dev@noladev.com> |
| 7 | * @copyright Copyright (c) 2009-2025 NOLA Interactive, LLC. |
| 8 | * @license https://www.popphp.org/license New BSD License |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * @namespace |
| 13 | */ |
| 14 | namespace Pop\Queue\Process; |
| 15 | |
| 16 | use Pop\Application; |
| 17 | |
| 18 | /** |
| 19 | * Job interface |
| 20 | * |
| 21 | * @category Pop |
| 22 | * @package Pop\Queue |
| 23 | * @author Nick Sagona, III <dev@noladev.com> |
| 24 | * @copyright Copyright (c) 2009-2025 NOLA Interactive, LLC. |
| 25 | * @license https://www.popphp.org/license New BSD License |
| 26 | * @version 2.1.2 |
| 27 | */ |
| 28 | interface JobInterface |
| 29 | { |
| 30 | |
| 31 | /** |
| 32 | * Generate job ID |
| 33 | * |
| 34 | * @return string |
| 35 | */ |
| 36 | public function generateJobId(): string; |
| 37 | |
| 38 | /** |
| 39 | * Set job ID |
| 40 | * |
| 41 | * @param string $id |
| 42 | * @return JobInterface |
| 43 | */ |
| 44 | public function setJobId(string $id): JobInterface; |
| 45 | |
| 46 | /** |
| 47 | * Get job ID |
| 48 | * |
| 49 | * @return ?string |
| 50 | */ |
| 51 | public function getJobId(): ?string; |
| 52 | |
| 53 | /** |
| 54 | * Has job ID |
| 55 | * |
| 56 | * @return bool |
| 57 | */ |
| 58 | public function hasJobId(): bool; |
| 59 | |
| 60 | /** |
| 61 | * Set job description |
| 62 | * |
| 63 | * @param string $description |
| 64 | * @return JobInterface |
| 65 | */ |
| 66 | public function setJobDescription(string $description): JobInterface; |
| 67 | |
| 68 | /** |
| 69 | * Get job description |
| 70 | * |
| 71 | * @return ?string |
| 72 | */ |
| 73 | public function getJobDescription(): ?string; |
| 74 | |
| 75 | /** |
| 76 | * Has job description |
| 77 | * |
| 78 | * @return bool |
| 79 | */ |
| 80 | public function hasJobDescription(): bool; |
| 81 | |
| 82 | /** |
| 83 | * Get job results |
| 84 | * |
| 85 | * @return mixed |
| 86 | */ |
| 87 | public function getResults(): mixed; |
| 88 | |
| 89 | /** |
| 90 | * Has job results |
| 91 | * |
| 92 | * @return bool |
| 93 | */ |
| 94 | public function hasResults(): bool; |
| 95 | |
| 96 | /** |
| 97 | * Set job callable |
| 98 | * |
| 99 | * @param mixed $callable |
| 100 | * @param mixed $params |
| 101 | * @return JobInterface |
| 102 | */ |
| 103 | public function setCallable(mixed $callable, mixed $params = null): JobInterface; |
| 104 | |
| 105 | /** |
| 106 | * Set job application command |
| 107 | * |
| 108 | * @param string $command |
| 109 | * @return JobInterface |
| 110 | */ |
| 111 | public function setCommand(string $command): JobInterface; |
| 112 | |
| 113 | /** |
| 114 | * Set job CLI executable command |
| 115 | * |
| 116 | * @param string $command |
| 117 | * @return JobInterface |
| 118 | */ |
| 119 | public function setExec(string $command): JobInterface; |
| 120 | |
| 121 | /** |
| 122 | * Get job callable |
| 123 | * |
| 124 | * @return mixed |
| 125 | */ |
| 126 | public function getCallable(): mixed; |
| 127 | |
| 128 | /** |
| 129 | * Get job application command |
| 130 | * |
| 131 | * @return ?string |
| 132 | */ |
| 133 | public function getCommand(): ?string; |
| 134 | |
| 135 | /** |
| 136 | * Get job CLI executable command |
| 137 | * |
| 138 | * @return ?string |
| 139 | */ |
| 140 | public function getExec(): ?string; |
| 141 | |
| 142 | /** |
| 143 | * Has job callable |
| 144 | * |
| 145 | * @return bool |
| 146 | */ |
| 147 | public function hasCallable(): bool; |
| 148 | |
| 149 | /** |
| 150 | * Has job application command |
| 151 | * |
| 152 | * @return bool |
| 153 | */ |
| 154 | public function hasCommand(): bool; |
| 155 | |
| 156 | /** |
| 157 | * Has job CLI executable command |
| 158 | * |
| 159 | * @return bool |
| 160 | */ |
| 161 | public function hasExec(): bool; |
| 162 | |
| 163 | /** |
| 164 | * Set max attempts |
| 165 | * |
| 166 | * @param int $maxAttempts |
| 167 | * @return JobInterface |
| 168 | */ |
| 169 | public function setMaxAttempts(int $maxAttempts): JobInterface; |
| 170 | |
| 171 | /** |
| 172 | * Get max attempts |
| 173 | * |
| 174 | * @return int |
| 175 | */ |
| 176 | public function getMaxAttempts(): int; |
| 177 | |
| 178 | /** |
| 179 | * Has max attempts |
| 180 | * |
| 181 | * @return bool |
| 182 | */ |
| 183 | public function hasMaxAttempts(): bool; |
| 184 | |
| 185 | /** |
| 186 | * Is job set for only one max attempt |
| 187 | * |
| 188 | * @return bool |
| 189 | */ |
| 190 | public function isAttemptOnce(): bool; |
| 191 | |
| 192 | /** |
| 193 | * Get actual attempts |
| 194 | * |
| 195 | * @return int |
| 196 | */ |
| 197 | public function getAttempts(): int; |
| 198 | |
| 199 | /** |
| 200 | * Has actual attempts |
| 201 | * |
| 202 | * @return bool |
| 203 | */ |
| 204 | public function hasAttempts(): bool; |
| 205 | |
| 206 | /** |
| 207 | * Set the run until property |
| 208 | * |
| 209 | * @param int|string $runUntil |
| 210 | * @return JobInterface |
| 211 | */ |
| 212 | public function runUntil(int|string $runUntil): JobInterface; |
| 213 | |
| 214 | /** |
| 215 | * Has run until |
| 216 | * |
| 217 | * @return bool |
| 218 | */ |
| 219 | public function hasRunUntil(): bool; |
| 220 | |
| 221 | /** |
| 222 | * Get run until value |
| 223 | * |
| 224 | * @return int|string|null |
| 225 | */ |
| 226 | public function getRunUntil(): int|string|null; |
| 227 | |
| 228 | /** |
| 229 | * Determine if the job has expired |
| 230 | * |
| 231 | * @return bool |
| 232 | */ |
| 233 | public function isExpired(): bool; |
| 234 | |
| 235 | /** |
| 236 | * Determine if the job has exceeded max attempts |
| 237 | * |
| 238 | * @return bool |
| 239 | */ |
| 240 | public function hasExceededMaxAttempts(): bool; |
| 241 | |
| 242 | /** |
| 243 | * Determine if the job is still valid |
| 244 | * |
| 245 | * @return bool |
| 246 | */ |
| 247 | public function isValid(): bool; |
| 248 | |
| 249 | /** |
| 250 | * Has job run yet |
| 251 | * |
| 252 | * @return bool |
| 253 | */ |
| 254 | public function hasNotRun(): bool; |
| 255 | |
| 256 | /** |
| 257 | * Start job |
| 258 | * |
| 259 | * @return JobInterface |
| 260 | */ |
| 261 | public function start(): JobInterface; |
| 262 | |
| 263 | /** |
| 264 | * Get started timestamp |
| 265 | * |
| 266 | * @return ?int |
| 267 | */ |
| 268 | public function getStarted(): ?int; |
| 269 | |
| 270 | /** |
| 271 | * Has job started |
| 272 | * |
| 273 | * @return bool |
| 274 | */ |
| 275 | public function hasStarted(): bool; |
| 276 | |
| 277 | /** |
| 278 | * Is job running and has not completed or failed yet |
| 279 | * |
| 280 | * @return bool |
| 281 | */ |
| 282 | public function isRunning(): bool; |
| 283 | |
| 284 | /** |
| 285 | * Complete job |
| 286 | * |
| 287 | * @return JobInterface |
| 288 | */ |
| 289 | public function complete(): JobInterface; |
| 290 | |
| 291 | /** |
| 292 | * Get completed timestamp |
| 293 | * |
| 294 | * @return ?int |
| 295 | */ |
| 296 | public function getCompleted(): ?int; |
| 297 | |
| 298 | /** |
| 299 | * Is job complete |
| 300 | * |
| 301 | * @return bool |
| 302 | */ |
| 303 | public function isComplete(): bool; |
| 304 | |
| 305 | /** |
| 306 | * Set job as failed |
| 307 | * |
| 308 | * @param ?string $message |
| 309 | * @return AbstractJob |
| 310 | */ |
| 311 | function failed(?string $message = null): JobInterface; |
| 312 | |
| 313 | /** |
| 314 | * Has job failed |
| 315 | * |
| 316 | * @return bool |
| 317 | */ |
| 318 | public function hasFailed(): bool; |
| 319 | |
| 320 | /** |
| 321 | * Add failed message |
| 322 | * |
| 323 | * @param string $message |
| 324 | * @return JobInterface |
| 325 | */ |
| 326 | public function addFailedMessage(string $message): JobInterface; |
| 327 | |
| 328 | /** |
| 329 | * Has failed messages |
| 330 | * |
| 331 | * @return bool |
| 332 | */ |
| 333 | public function hasFailedMessages(): bool; |
| 334 | |
| 335 | /** |
| 336 | * Get failed messages |
| 337 | * |
| 338 | * @return array |
| 339 | */ |
| 340 | public function getFailedMessages(): array; |
| 341 | |
| 342 | /** |
| 343 | * Get failed timestamp |
| 344 | * |
| 345 | * @return ?int |
| 346 | */ |
| 347 | public function getFailed(): ?int; |
| 348 | |
| 349 | /** |
| 350 | * Run job |
| 351 | * |
| 352 | * @param ?Application $application |
| 353 | * @return mixed |
| 354 | */ |
| 355 | public function run(?Application $application = null): mixed; |
| 356 | |
| 357 | } |