Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2019-12-16 (2 days ago) | | Not yet rated by the users | | Total: 1 This week: 1 | | All time: 9,803 This week: 349 |
|
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. | |
|
|
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."
// }
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.