PHP Classes

Easy PHP Circuit Breaker: Check the status of circuit breaker conditions

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 35 All time: 11,005 This week: 560Up
Version License PHP version Categories
php-easy-breaker 1.0The PHP License7Language, Design Patterns, PHP 7
Description 

Author

This package can be used to check the status of circuit breaker conditions.

It can create breaker objects that register breaker conditions by passing exceptions to be caught and functions that return strings which define messages to be returned when breaker conditions occur.

The package can also add one or more breaker objects to be evaluated to determine if at least one of the breaker conditions occurred and the application may have to be stopped.

Picture of DeGraciaMathieu
  Performance   Level  
Name: DeGraciaMathieu <contact>
Classes: 21 packages by
Country: France France
Age: ???
All time rank: 289780 in France France
Week rank: 18 Up2 in France France Up
Innovation award
Innovation award
Nominee: 15x

Winner: 2x

Documentation

<p align="center"> <a href="https://travis-ci.org/DeGraciaMathieu/php-easy-breaker"><img src="https://travis-ci.org/DeGraciaMathieu/php-easy-breaker.svg?branch=master" alt="Build Status"></a> <a href="https://scrutinizer-ci.com/g/DeGraciaMathieu/php-easy-breaker/?branch=master"><img src="https://scrutinizer-ci.com/g/DeGraciaMathieu/php-easy-breaker/badges/coverage.png?b=master" alt="Code Coverage"></a> <img src="https://img.shields.io/travis/php-v/DeGraciaMathieu/php-easy-breaker.svg" alt="PHP range"> <a href="https://packagist.org/packages/degraciamathieu/php-easy-breaker"><img src="https://img.shields.io/packagist/v/degraciamathieu/php-easy-breaker.svg?style=flat-square" alt="Latest Version on Packagist"></a> <a href='https://packagist.org/packages/degraciamathieu/php-easy-breaker'><img src='https://img.shields.io/packagist/dt/degraciamathieu/php-easy-breaker.svg?style=flat-square' /></a> </p>

degraciamathieu/php-easy-breaker

PHP implementation of circuit breaker pattern.

Installation

Run in console below command to download package to your project:

composer require degraciamathieu/php-easy-breaker

usage

require __DIR__.'/vendor/autoload.php';

use Exception;
use DeGraciaMathieu\EasyBreaker\Breaker;
use DeGraciaMathieu\EasyBreaker\CircuitBreaker;

$firstBreaker = (new Breaker)
    ->when(Exception::class)
    ->do(function(Exception $e){
        return "it's broken.";
    });

$secondBreaker = (new Breaker)
    ->when(Exception::class)
    ->do(function(Exception $e){
        return "realy broken.";
    });

$thirdBreaker = (new Breaker)
    ->when(AnotherException::class)
    ->do(function(AnotherException $e){
        return "boom.";
    });

$results = (new CircuitBreaker())
    ->addBreaker($firstBreaker)
    ->addBreaker($secondBreaker)
    ->addBreaker($thirdBreaker)
    ->closure(function(){
        throw new Exception();
    });

var_dump($results);

// array(2) {
//   [0]=>
//   string(12) "it's broken."
//   [1]=>
//   string(18) "realy broken."
// }

  Files folder image Files (8)  
File Role Description
Files folder imagesrc (3 files)
Files folder imagetests (1 file)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (8)  /  src  
File Role Description
  Plain text file Breaker.php Class Class source
  Plain text file BreakerAggregator.php Class Class source
  Plain text file CircuitBreaker.php Class Class source

  Files folder image Files (8)  /  tests  
File Role Description
  Plain text file CircuitBreakerTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:35
This week:0
All time:11,005
This week:560Up