rymanalu/laravel-circuit-breaker

Circuit Breaker pattern implementation in Laravel 5.
1,192 5
Install
composer require rymanalu/laravel-circuit-breaker
Latest Version:v1.0.1
PHP:>=5.5.9
License:MIT
Last Updated:Dec 8, 2016
Links: GitHub  ·  Packagist
Maintainer: rymanalu

Laravel 5 Circuit Breaker

Build Status

This package provides an implementation of Circuit Breaker pattern for Laravel 5.

Installation

First, install this package:

composer require rymanalu/laravel-circuit-breaker

Next, add the ServiceProvider to the providers array in config/app.php:

Rymanalu\LaravelCircuitBreaker\CircuitBreakerServiceProvider::class,

You can use the facade for shorter code. Add this to your aliases:

'CircuitBreaker' => Rymanalu\LaravelCircuitBreaker\CircuitBreakerFacade::class,

APIs

<?php

use CircuitBreaker;

/**
 * Get the number of failures for the given key.
 *
 * @param  string  $key
 * @return int
 */
CircuitBreaker::failures($key);

/**
 * Reset the number of failures for the given key.
 *
 * @param  string  $key
 * @return bool
 */
CircuitBreaker::resetFailures($key);

/**
 * Increment the counter for a given key for a given decay time.
 *
 * @param  string  $key
 * @param  float|int  $decayMinutes
 * @return int
 */
CircuitBreaker::track($key, $decayMinutes = 1);

/**
 * Determine if the given key has too many failures.
 *
 * @param  string  $key
 * @param  int  $maxFailures
 * @param  int  $decayMinutes
 * @return bool
 */
CircuitBreaker::tooManyFailures($key, $maxFailures, $decayMinutes = 1);

Related Packages

maystro/filament-popup-modal

A comprehensive modal dialog system for FilamentPHP with progress bars, callback...

7 1
andhikamaheva/date

A date library to help you work with dates in different languages

13 1
vlados/laravel-blade-crawler-detect

Boost Lighthouse and PageSpeed scores by hiding cookie banners, chat widgets and...

5,257 0
wobeto/twitter

Laravel 4 Service Provider to interact with twitter account, like return a colle...

135 1