Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/nativephp.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
'queues' => ['default'],
'memory_limit' => 128,
'timeout' => 60,
'sleep' => 3,
],
],

Expand Down
2 changes: 2 additions & 0 deletions src/DTOs/QueueConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function __construct(
public readonly array $queuesToConsume,
public readonly int $memoryLimit,
public readonly int $timeout,
public readonly int $sleep,
) {}

/**
Expand All @@ -26,6 +27,7 @@ function (array|string $worker, string $alias) {
$worker['queues'] ?? ['default'],
$worker['memory_limit'] ?? 128,
$worker['timeout'] ?? 60,
$worker['sleep'] ?? 3,
);
},
$config,
Expand Down
1 change: 1 addition & 0 deletions src/QueueWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function up(string|QueueConfig $config): void
'--queue='.implode(',', $config->queuesToConsume),
"--memory={$config->memoryLimit}",
"--timeout={$config->timeout}",
"--sleep={$config->sleep}",
],
'queue_'.$config->alias,
persistent: true,
Expand Down
5 changes: 5 additions & 0 deletions tests/DTOs/QueueWorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
fn (QueueConfig $config) => $config->alias === $worker)))->memoryLimit->toBe(128);
expect(Arr::first(array_filter($configObject,
fn (QueueConfig $config) => $config->alias === $worker)))->timeout->toBe(60);
expect(Arr::first(array_filter($configObject,
fn (QueueConfig $config) => $config->alias === $worker)))->sleep->toBe(3);

continue;
}
Expand All @@ -35,6 +37,8 @@
fn (QueueConfig $config) => $config->alias === $alias)))->memoryLimit->toBe($worker['memory_limit'] ?? 128);
expect(Arr::first(array_filter($configObject,
fn (QueueConfig $config) => $config->alias === $alias)))->timeout->toBe($worker['timeout'] ?? 60);
expect(Arr::first(array_filter($configObject,
fn (QueueConfig $config) => $config->alias === $alias)))->sleep->toBe($worker['sleep'] ?? 3);
}
})->with([
[
Expand All @@ -44,6 +48,7 @@
'queues' => ['default'],
'memory_limit' => 64,
'timeout' => 60,
'sleep' => 3,
],
],
],
Expand Down
4 changes: 2 additions & 2 deletions tests/Fakes/FakeQueueWorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
it('asserts up using callable', function () {
swap(QueueWorkerContract::class, $fake = app(QueueWorkerFake::class));

$fake->up(new QueueConfig('testA', ['default'], 123, 123));
$fake->up(new QueueConfig('testB', ['default'], 123, 123));
$fake->up(new QueueConfig('testA', ['default'], 123, 123, 0));
$fake->up(new QueueConfig('testB', ['default'], 123, 123, 0));

$fake->assertUp(fn (QueueConfig $up) => $up->alias === 'testA');
$fake->assertUp(fn (QueueConfig $up) => $up->alias === 'testB');
Expand Down
3 changes: 2 additions & 1 deletion tests/QueueWorker/QueueWorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

$workerName = 'some_worker';

$config = new QueueConfig($workerName, ['default'], 128, 61);
$config = new QueueConfig($workerName, ['default'], 128, 61, 5);

QueueWorker::up($config);

Expand All @@ -20,6 +20,7 @@
'--queue=default',
'--memory=128',
'--timeout=61',
'--sleep=5',
]);

expect($iniSettings)->toBe([
Expand Down
Loading