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

Limit ExponentialBackoff to specifying just $backoff #9

Merged
merged 2 commits into from
Mar 7, 2024
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ See [GitHub releases](https://github.com/mll-lab/laravel-utils/releases).

## Unreleased

## v4.9.0

### Changed

- Limit `ExponentialBackoff` to specifying just `$backoff`

## v4.8.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/ModelStates/StateEnumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class StateEnumType extends EnumType
* @param class-string<State> $stateClass
* @param string|null $name The name the enum will have in the schema, defaults to the basename of the given class
*/
public function __construct(string $stateClass, string $name = null)
public function __construct(string $stateClass, ?string $name = null)
{
// @phpstan-ignore-next-line php-stan is not right here
if (! is_subclass_of($stateClass, State::class)) {
Expand Down
13 changes: 3 additions & 10 deletions src/Queue/ExponentialBackoff.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace MLL\LaravelUtils\Queue;

/**
* Sane defaults for handling unexpected exceptions in jobs.
* Sane values for exponentially rising backoff times for failed jobs.
*
* - frees worker resources from jobs that are likely to never succeed
* - prevents flooding Sentry with an ever-repeating error report
Expand All @@ -13,21 +13,14 @@
*/
trait ExponentialBackoff
{
/**
* The maximum number of unhandled exceptions to allow before failing.
*
* https://laravel.com/docs/queues#max-exceptions
*/
public int $maxExceptions = 10;

/**
* The amount of seconds to wait before retrying the job.
*
* We go up to a maximum interval of 64 seconds to ensure the waiting
* time between attempts is not too long.
*
* Combined with $maxExceptions, the duration adds up to just over
* 5 minutes total, after which the job fails.
* The duration for 10 tries adds up to just over 5 minutes total,
* after which the job fails.
*
* https://laravel.com/docs/queues#dealing-with-failed-jobs
*/
Expand Down