forked from tradecoverexchange/google-cloud-tasks-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueueInteractionCommand.php
35 lines (28 loc) · 1.05 KB
/
QueueInteractionCommand.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
<?php
namespace TradeCoverExchange\GoogleCloudTaskLaravel;
use Illuminate\Console\Command;
use Illuminate\Contracts\Container\Container;
use Illuminate\Queue\QueueManager;
abstract class QueueInteractionCommand extends Command
{
use ConnectionRetrieval;
public function handle(Container $container, QueueManager $manager): int
{
[$connectionName, $queueName] = array_pad(explode(':', $this->argument('name')), 2, null);
$queue = $manager->connection($connectionName);
$config = $this->getConfig($connectionName);
$namespaceName = implode(':', [$connectionName, $queueName ?? $config['queue']]);
if (! $queue instanceof Queue) {
throw new \LogicException();
}
$client = $queue->client();
return (int) $container->call([$this, 'action'], [
'name' => $connectionName,
'namespaceName' => $namespaceName,
'queueName' => $queueName,
'client' => $client,
'config' => $config,
'queue' => $queue,
]);
}
}