-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAdapter.php
More file actions
63 lines (52 loc) · 1.31 KB
/
Adapter.php
File metadata and controls
63 lines (52 loc) · 1.31 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
<?php
namespace Utopia\Queue;
abstract class Adapter
{
public int $workerNum;
/**
* @var array<string> $queues
*/
public array $queues;
public string $namespace;
public Connection $connection;
public function __construct(int $workerNum, string $queue, string $namespace = 'utopia-queue')
{
$this->workerNum = $workerNum;
$this->queues = [$queue];
$this->namespace = $namespace;
}
public function addQueue(string $queue): self
{
if (!(\in_array($queue, $this->queues))) {
$this->queues[] = $queue;
}
return $this;
}
/**
* Starts the Server.
* @return self
*/
abstract public function start(): self;
/**
* Stops the Server.
* @return self
*/
abstract public function stop(): self;
/**
* Is called when a Worker starts.
* @param callable $callback
* @return self
*/
abstract public function workerStart(callable $callback): self;
/**
* Is called when a Worker stops.
* @param callable $callback
* @return self
*/
abstract public function workerStop(callable $callback): self;
/**
* Returns the native server object from the Adapter.
* @return mixed
*/
abstract public function getNative(): mixed;
}