Skip to content

Commit

Permalink
Merge pull request #177 from keboola/zajca-ct-1894-customize-retry
Browse files Browse the repository at this point in the history
CT-1894 allow customize number of reties and backoff policy for runJob
  • Loading branch information
zajca authored Dec 18, 2024
2 parents 22a52bd + b901e8f commit 41f7f29
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ public function runQuery(JobConfigurationInterface $query, array $options = []):
*/
public function runJob(JobConfigurationInterface $config, array $options = []): Job
{
$retryPolicy = new SimpleRetryPolicy(5);
$backOffPolicy = new ExponentialRandomBackOffPolicy(10, 1.8, 300);
$proxy = new RetryProxy($retryPolicy, $backOffPolicy);
$options += [
'retryCount' => 5,
'backOffPolicy' => new ExponentialRandomBackOffPolicy(10, 1.8, 300),
];
assert(is_int($options['retryCount']) && $options['retryCount'] > 0);
assert($options['backOffPolicy'] instanceof BackOffPolicyInterface);
$retryPolicy = new SimpleRetryPolicy($options['retryCount']);
$proxy = new RetryProxy($retryPolicy, $options['backOffPolicy']);
$job = $proxy->call(function () use ($config, $options): Job {
return $this->startJob($config, $options);
});
Expand Down

0 comments on commit 41f7f29

Please sign in to comment.