Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit 8163bfe

Browse files
committed
Add connectionName
1 parent ca07ab2 commit 8163bfe

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/AsyncQueue.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class AsyncQueue extends DatabaseQueue
1212

1313
/** @var string */
1414
protected $binaryArgs;
15+
16+
/** @var string */
17+
protected $connectionName;
1518

1619
/**
1720
* @param \Illuminate\Database\Connection $database
@@ -21,11 +24,12 @@ class AsyncQueue extends DatabaseQueue
2124
* @param string $binary
2225
* @param string|array $binaryArgs
2326
*/
24-
public function __construct(Connection $database, $table, $default = 'default', $expire = 60, $binary = 'php', $binaryArgs = '')
27+
public function __construct(Connection $database, $table, $default = 'default', $expire = 60, $binary = 'php', $binaryArgs = '', $connectionName = '')
2528
{
2629
parent::__construct($database, $table, $default, $expire);
2730
$this->binary = $binary;
2831
$this->binaryArgs = $binaryArgs;
32+
$this->connectionName = $connectionName;
2933
}
3034

3135
/**
@@ -144,14 +148,14 @@ public function startProcess($queue, $id)
144148
*/
145149
protected function getCommand($queue, $id)
146150
{
147-
$connection = null;
148-
$cmd = '%s artisan queue:async %d %d --env=%s --queue=%s';
151+
$connection = $this->connectionName;
152+
$cmd = '%s artisan queue:async %d %s --env=%s --queue=%s';
149153
$cmd = $this->getBackgroundCommand($cmd);
150154

151155
$binary = $this->getPhpBinary();
152156
$environment = $this->container->environment();
153157

154-
return sprintf($cmd, $binary, $id, $connection, $environment, $queue);
158+
return sprintf($cmd, $binary, $id, $connection, $environment, $this->getQueue($queue));
155159
}
156160

157161
/**

src/Connectors/AsyncConnector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ class AsyncConnector extends DatabaseConnector
1717
*/
1818
public function connect(array $config)
1919
{
20+
var_dump($config);
2021
return new AsyncQueue(
2122
$this->connections->connection(array_get($config, 'connection')),
2223
$config['table'],
2324
$config['queue'],
2425
array_get($config, 'expire', 60),
2526
array_get($config, 'binary', 'php'),
26-
array_get($config, 'binary_args', '')
27+
array_get($config, 'binary_args', ''),
28+
array_get($config, 'connection_name', '')
2729
);
2830
}
2931
}

0 commit comments

Comments
 (0)