-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathAdapterInterface.php
More file actions
40 lines (33 loc) · 1.27 KB
/
AdapterInterface.php
File metadata and controls
40 lines (33 loc) · 1.27 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
<?php
declare(strict_types=1);
namespace Yiisoft\Queue\Adapter;
use InvalidArgumentException;
use Yiisoft\Queue\JobStatus;
use Yiisoft\Queue\Message\MessageInterface;
interface AdapterInterface
{
/**
* Returns the first message from the queue if it exists (null otherwise).
*
* @param callable(MessageInterface): bool $handlerCallback The handler which will handle messages. Returns false if it cannot continue handling messages
*/
public function runExisting(callable $handlerCallback): void;
/**
* Returns status code of a message with the given id.
*
* @param int|string $id ID of a job message.
*
* @throws InvalidArgumentException When there is no such id in the adapter.
*/
public function status(string|int $id): JobStatus;
/**
* Pushing a message to the queue. Adapter sets message ID if available.
*/
public function push(MessageInterface $message): MessageInterface;
/**
* Listen to the queue and pass messages to the given handler as they come.
*
* @param callable(MessageInterface): bool $handlerCallback The handler which will handle messages. Returns false if it cannot continue handling messages.
*/
public function subscribe(callable $handlerCallback): void;
}