Skip to content

Commit 82e462b

Browse files
committed
Allow workers to be instantiated directly by alias
1 parent a997774 commit 82e462b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/QueueWorker.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@ public function __construct(
1212
private readonly ChildProcessContract $childProcess,
1313
) {}
1414

15-
public function up(QueueConfig $config): void
15+
public function up(string|QueueConfig $config): void
1616
{
17+
if (is_string($config) && config()->has("nativephp.queue_workers.{$config}")) {
18+
$config = QueueConfig::fromConfigArray([
19+
$config => config("nativephp.queue_workers.{$config}")
20+
])[0];
21+
}
22+
23+
if (! $config instanceof QueueConfig) {
24+
throw new \InvalidArgumentException("Invalid queue configuration alias [$config]");
25+
}
26+
1727
$this->childProcess->php(
1828
[
1929
'-d',

0 commit comments

Comments
 (0)