-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo.php
More file actions
53 lines (43 loc) · 1.17 KB
/
demo.php
File metadata and controls
53 lines (43 loc) · 1.17 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
<?php
require __DIR__ . '/../vendor/autoload.php';
// Setup Queue
$redis = new Redis();
$redis->connect('localhost');
$driver = new \Equip\Queue\Driver\RedisDriver($redis);
$queue = new \Equip\Queue\Queue($driver);
$queue_middleware = new \Equip\Queue\QueueMiddleware(
$queue,
[
'test' => [
\Example\ExampleCommand::class,
],
]
);
// Setup Tactician
$locator = new \League\Tactician\Handler\Locator\InMemoryLocator([
\Example\ExampleCommand::class => new \Example\ExampleHandler(),
]);
$handler_middleware = new \League\Tactician\Handler\CommandHandlerMiddleware(
new \League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor(),
$locator,
new \League\Tactician\Handler\MethodNameInflector\HandleInflector()
);
$bus = new \League\Tactician\CommandBus([
$queue_middleware,
$handler_middleware,
]);
// Setup worker
$worker = new \Equip\Queue\Worker(
$driver,
$queue,
new \Equip\Queue\Event(
new \League\Event\Emitter(),
new \Monolog\Logger('queue')
),
$bus
);
if ($argv[1] == 'produce') {
$bus->handle(new \Example\ExampleCommand());
} else {
$worker->consume('test');
}