saloon icon indicating copy to clipboard operation
saloon copied to clipboard

Add methods to dynamically set/unset retry options

Open viicslen opened this issue 5 months ago • 0 comments

This PR adds methods in the HasTries trait to allow the retry options to be set dynamically (mainly when using resources)

$this->connector
	->withRetry(tries: 3, intervalMilliseconds: 1000, exponentialBackoff: true, , throwOnMaxTries: true)
	->admin()
	->externalProducts()
	->upsertExternalProduct($productId, $data);


$this->connector
	->withRetry(3)
	->withRetryInterval(1000)
	->withExponentialBackoff()
	->throwOnMaxTries()
	->admin()
	->externalProducts()
	->upsertExternalProduct($productId, $data)

This will also allow to unset these options for specific requests

$this->connector
	->withoutRetry()
	->admin()
	->externalProducts()
	->upsertExternalProduct($productId, $data);


$this->connector
	->withRetry(3)
	->withRetryInterval(null)
	->withExponentialBackoff(false)
	->throwOnMaxTries(false)
	->admin()
	->externalProducts()
	->upsertExternalProduct($productId, $data)

$this->connector
	->withRetry(3)
	->withoutRetryInterval()
	->withoutExponentialBackoff()
	->throwOnMaxTries(false)
	->admin()
	->externalProducts()
	->upsertExternalProduct($productId, $data)

This is just a draft PR, it would still be missing tests and method comments to follow the other methods in the trait, I will happily add them if you thing this would be a good addition

To Do:

  • [ ] Tests
  • [ ] Method docblocks

viicslen avatar Sep 04 '24 18:09 viicslen