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

Creating new strategies #114

Open
maxbaldanza opened this issue Apr 10, 2024 · 4 comments
Open

Creating new strategies #114

maxbaldanza opened this issue Apr 10, 2024 · 4 comments

Comments

@maxbaldanza
Copy link
Contributor

Hi,

Great package 🙌

We'd like to create a new strategy that opens the circuit if a request takes too long for example if a request took longer then 5s X times in X seconds. One way to achieve this is to set the timeout in Guzzle/http client which would throw an exception but the problem with this is that we want the request to continue to process rather than throw an exception after a certain timeout.
Therefore we we're thinking of creating a new Strategy that would track the time it took to process and either say success/failure based on this time.

The problem we have is how we set the Configuration for this timeout because this gets passed to the service but the configuration for this Strategy will be different to the existing ones. Any plans/thoughts on how to change the configuration for new strategies?

@maxbaldanza
Copy link
Contributor Author

maxbaldanza commented Apr 16, 2024

Happy to help by the way but I suspect the changes needed may be breaking changes so just thought I'd gather feedback first

@maxbaldanza
Copy link
Contributor Author

@ackintosh would love to get your thoughts on this 😄

@TheCelavi
Copy link

@maxbaldanza Sorry to meddle - I was investigating similar idea, but it seams that new strategy is not necessary to have same functionality. Our approach is to wait for request to complete, check the response time and if it is longer than acceptable (per example, 10s and we expected 2 or less) we report that as failure.

Logic behind that is that endpoint is obviously in serious problem and it will probably crash very soon, so we are backing off earlier to give it a breather.

For this, we are using custom guzzle middleware.

Does this have any value to you? Please, share your thoughts - do you have different idea?

Thanks :)

@maxbaldanza
Copy link
Contributor Author

Thanks for reaching out @TheCelavi, it's always great to hear how others have solved the same problem 🙌

I think the approach you have there sounds great.
It's been a while so I can't quite remember the details and in the end we didn't need this functionality so I can't quite remember why we didn't go down that route.

Either way, I think my point is still valid that it'd be great to be able to be able to create new strategies which doesn't seem possible at the minute because of the way a lot of things are not extendible.

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

No branches or pull requests

2 participants