PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-12-16 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 25 All time: 9,788 This week: 331Up
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.

  Performance   Level  
Name: DeGraciaMathieu <contact>
Classes: 6 packages by
Country: France France
Age: ???
All time rank: 368191 in France France
Week rank: 683 Up19 in France France Up
Innovation award
Innovation award
Nominee: 2x

 

Details

<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  
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  /  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  /  tests  
File Role Description
  Plain text file CircuitBreakerTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:25
This week:0
All time:9,788
This week:331Up