Source: medium.com

Circuit Breaker in Laravel

Category: Laravel, PHP, api

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.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners