-
Notifications
You must be signed in to change notification settings - Fork 0
/
Driver.php
72 lines (57 loc) · 1.54 KB
/
Driver.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
<?php
declare(strict_types=1);
namespace Bernard\Driver\AppEngine;
use Bernard\Driver\Message;
use google\appengine\api\taskqueue\PushTask;
/**
* Google App Engine driver. Many features are not supported.
* It takes a list of array('name' => 'endpoint') to route messages to the
* correct place.
*/
final class Driver implements \Bernard\Driver
{
public function __construct(private array $queueMap)
{
}
public function listQueues(): array
{
return array_flip($this->queueMap);
}
public function createQueue(string $queueName): void
{
}
public function removeQueue(string $queueName): void
{
}
public function pushMessage(string $queueName, string $message): void
{
$task = new PushTask($this->resolveEndpoint($queueName), compact('message'));
$task->add($queueName);
}
public function popMessage(string $queueName, int $duration = 5): ?Message
{
return null;
}
public function acknowledgeMessage(string $queueName, mixed $receipt): void
{
}
public function info(): array
{
return [];
}
public function countMessages(string $queueName): int
{
return 0;
}
public function peekQueue(string $queueName, int $index = 0, int $limit = 20): array
{
return [];
}
private function resolveEndpoint(string $queueName): string
{
if (isset($this->queueMap[$queueName])) {
return $this->queueMap[$queueName];
}
return '/_ah/queue/'.$queueName;
}
}