Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Accept array format for exponential backoff #926

Merged
merged 1 commit into from Nov 19, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ProvisioningPlan.php
Expand Up @@ -172,6 +172,7 @@ protected function convert($supervisor, $options)
$key = $key === 'tries' ? 'max_tries' : $key;
$key = $key === 'processes' ? 'max_processes' : $key;
$value = $key === 'queue' && is_array($value) ? implode(',', $value) : $value;
$value = $key === 'backoff' && is_array($value) ? implode(',', $value) : $value;

return [Str::camel($key) => $value];
})->all();
Expand Down
2 changes: 1 addition & 1 deletion src/SupervisorOptions.php
Expand Up @@ -91,7 +91,7 @@ class SupervisorOptions
/**
* The number of seconds to wait before retrying a job that encountered an uncaught exception.
*
* @var int
* @var string
*/
public $backoff;

Expand Down
17 changes: 17 additions & 0 deletions tests/Feature/ProvisioningPlanTest.php
Expand Up @@ -98,4 +98,21 @@ public function test_plan_is_converted_into_array_of_supervisor_options()

$this->assertSame(20, $results['local']['supervisor-2']->maxProcesses);
}

public function test_backoff_is_translated_to_string_form()
{
$plan = [
'local' => [
'supervisor-2' => [
'connection' => 'redis',
'queue' => 'local-supervisor-2-queue',
'backoff' => [30, 60],
],
],
];

$results = (new ProvisioningPlan(MasterSupervisor::name(), $plan))->toSupervisorOptions();

$this->assertSame('30,60', $results['local']['supervisor-2']->backoff);
}
}