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

Feature | Add methods to dynamically set/unset retry options #454

Draft
wants to merge 3 commits into
base: v3
Choose a base branch
from

Conversation

viicslen
Copy link

@viicslen viicslen commented Sep 4, 2024

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

@Sammyjo20
Copy link
Member

I've wanted this myself for quite a while, so yes @viicslen I'd love this! Thank you for the suggestion, if you could add tests etc let me know and I'll review it :)

@Sammyjo20 Sammyjo20 changed the title Add methods to dynamically set/unset retry options Feature | Add methods to dynamically set/unset retry options Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants