Skip to content

Commit

Permalink
Merge pull request #736 from themsaid/retryUntil
Browse files Browse the repository at this point in the history
Reset the retryUntil value
  • Loading branch information
taylorotwell authored Dec 30, 2019
2 parents 025f953 + 9f03b42 commit b1df832
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Jobs/RetryFailedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Laravel\Horizon\Jobs;

use Cake\Chronos\Chronos;
use Illuminate\Contracts\Queue\Factory as Queue;
use Laravel\Horizon\Contracts\JobRepository;
use Laravel\Horizon\JobId;
Expand Down Expand Up @@ -55,10 +56,26 @@ public function handle(Queue $queue, JobRepository $jobs)
*/
protected function preparePayload($id, $payload)
{
return json_encode(array_merge(json_decode($payload, true), [
$payload = json_decode($payload, true);

return json_encode(array_merge($payload, [
'id' => $id,
'attempts' => 0,
'retry_of' => $this->id,
'timeoutAt' => $this->prepareNewTimeout($payload),
]));
}

/**
* Prepare the timeout.
*
* @param array $payload
* @return int|null
*/
protected function prepareNewTimeout($payload)
{
return $payload['timeoutAt']
? Chronos::now()->addSeconds(ceil($payload['timeoutAt'] - $payload['pushedAt']))->getTimestamp()
: null;
}
}

0 comments on commit b1df832

Please sign in to comment.