Skip to content

Instantly share code, notes, and snippets.

@spout
Created August 18, 2022 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spout/c93405e150aa15c237539d9ef19954b6 to your computer and use it in GitHub Desktop.
Save spout/c93405e150aa15c237539d9ef19954b6 to your computer and use it in GitHub Desktop.
<?php
namespace App\Jobs\Traits;
trait ExponentialBackoffTrait
{
/**
* @return \Carbon\Carbon
* @link https://medium.com/maatwebsite/laravel-and-murphys-law-e22731be31d9
*/
public function retryAfter()
{
return now()->addSeconds(
(int) round(((2 ** $this->attempts()) - 1 ) / 2)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment