PHPackages                             acesseseucondominio/laravel-circuit-breaker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. acesseseucondominio/laravel-circuit-breaker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

acesseseucondominio/laravel-circuit-breaker
===========================================

A circuit breaker pattern implementation for the Laravel framework 5.5 based on laravel circuit breaker package https://github.com/francescomalatesta/laravel-circuit-breaker

09PHP

Since May 17Pushed 2y ago2 watchersCompare

[ Source](https://github.com/AcesseSeuCondominio/laravel-circuit-breaker)[ Packagist](https://packagist.org/packages/acesseseucondominio/laravel-circuit-breaker)[ RSS](/packages/acesseseucondominio-laravel-circuit-breaker/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel Circuit Breaker
=======================

[](#laravel-circuit-breaker)

An implementation of the Circuit Breaker pattern for Laravel Framework 5.6.

[![Latest Version on Packagist](https://camo.githubusercontent.com/56da7f3ced8aa2a1286b4f7624ef677d09f5b1624e145d71ee022c178e9a8e37/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6672616e636573636f6d616c6174657374612f6c61726176656c2d636972637569742d627265616b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/francescomalatesta/laravel-circuit-breaker)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/e61ece6cbda3e72cad53364eadeaf723af726e196444a4dd3b32054a9611abaa/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6672616e636573636f6d616c6174657374612f6c61726176656c2d636972637569742d627265616b65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/francescomalatesta/laravel-circuit-breaker)[![Quality Score](https://camo.githubusercontent.com/16515f13e5ea1829d94c4b7c897effa9b4205b68c67c5196be5a307f63ff99d1/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6672616e636573636f6d616c6174657374612f6c61726176656c2d636972637569742d627265616b65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/francescomalatesta/laravel-circuit-breaker)[![StyleCI](https://camo.githubusercontent.com/6a9331a410c713cb86481d752ebf321fec290e344170ea0397cd4645fe99f37a/68747470733a2f2f7374796c6563692e696f2f7265706f732f3133303032323835352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/130022855)

If you need an easy to use implementation of the [circuit breaker pattern](https://martinfowler.com/bliki/CircuitBreaker.html) for your Laravel application, you're in the right place.

**Note:** this package is based based on laravel circuit breaker package , in this repository was added compatibility for laravel 5.5 and bellow, tested only in laravel 5.5.

Install
-------

[](#install)

You can use Composer to install the package for your project.

```
$ composer require acesseseucondominio/laravel-circuit-breaker
```

Don't worry about service providers and façades: Laravel can auto discover the package without doing nothing!

Just remember to **publish the config file** with

```
php artisan vendor:publish
```

Usage
-----

[](#usage)

You will always use a single class (`CircuitBreaker` façade or `CircuitBreakerManager` class if you want to inject it) to work with this package.

Here's the methods reference:

### isAvailable(string $identifier) : bool

[](#isavailablestring-identifier--bool)

Returns `true` if the `$identifier` service is currently available. Returns `false` otherwise.

**Note:** you can use whatever you want as identifier. I like to use the `MyClass::class` name when possible.

### reportFailure(string $identifier) : void

[](#reportfailurestring-identifier--void)

Reports a failed attempt for the `$identifier` service. Take a look at the Configuration section below to know how attempts and failure times are managed.

### reportSuccess(string $identifier) : void

[](#reportsuccessstring-identifier--void)

Reports a successful attempt for the `$identifier` service. You can use it to mark a service as available and remove the "failed" status from it.

Configuration
-------------

[](#configuration)

### Defaults

[](#defaults)

By editing the `config/circuit_breaker.php` config file contents you will able to tweak the circuit breaker in a way that is more suitable for your needs.

You have three values under the `default` item:

```
