In this post, I will show you a package developed by me that you can import and you on your Laravel/PHP project.
A Circuit Breaker is one more example of it, and maybe you have heard this word before when talking to your electrician.
Do you agree that maybe if you call it X times in a given period, it is most likely that the external API is down or something else, and it will be a waste of resources and time if you keep trying it?
Let’s say that you are using the following settings: One of your services is a Payment Gateway, and you try to call it in an interval of each 2 seconds for some reason.
At this moment the circuit is open, it will stay “OPEN” for 30 seconds (time_out_open), and then it will change the state to “HALF_OPEN” at this moment, you can try to call the service again, and if it fails, it will be “OPEN” for more 30 seconds.