Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 35 | All time: 11,005 This week: 560 |
Version | License | PHP version | Categories | |||
php-easy-breaker 1.0 | The PHP License | 7 | Language, Design Patterns, PHP 7 |
Description | Author | |
This package can be used to check the status of circuit breaker conditions. |
<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>
PHP implementation of circuit breaker pattern.
Run in console below command to download package to your project:
composer require degraciamathieu/php-easy-breaker
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 (8) |
File | Role | Description | ||
---|---|---|---|---|
src (3 files) | ||||
tests (1 file) | ||||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (8) | / | src |
File | Role | Description |
---|---|---|
Breaker.php | Class | Class source |
BreakerAggregator.php | Class | Class source |
CircuitBreaker.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 |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.