A straightforward implementation of the Circuit Breaker pattern for Laravel 9

Overview

Laravel Circuit Breaker

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A straightforward implementation of the Circuit Breaker pattern for Laravel Framework 9 (using Memcached).

Installation

You can install the package via composer:

composer require leonardovee/laravel-circuit-breaker

You can publish the config file with:

php artisan vendor:publish --tag="circuit-breaker-config"

This is the contents of the published config file:

return [
    'memcached-server' => [
        'host' => '127.0.0.1',
        'port' => 11211
    ],
    'circuit-breaker' => [
        'failure-threshold' => 5,
        'half-open-timeout' => 5,
        'timeout' => 10
    ]
];

Usage

use LeonardoVee\CircuitBreaker\CircuitBreaker;

try {
    /** Make the request to your service */
    Http::get('https://my-service.com');
    
    /** Register a success on the circuit breaker */
    CircuitBreaker::setSuccess(circuitName: 'https://my-service.com');
} catch (Throwable $throwable) {
    /** Register a failure on the circuit breaker */
    CircuitBreaker::setFailure(circuitName: 'https://my-service.com');
}

/** Use to verify if the circuit is closed or open */
if (CircuitBreaker::isAvailable(circuitName: 'https://my-service.com')) {
    /** Do stuff */
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
Releases(v0.0.2)
Owner
Leonardo Vieira
Software Engineer | Tech Lead | @PicPay
Leonardo Vieira
Repository Pattern implementation for Laravel

This is a Simple Repository Pattern implementation for Laravel Projects and an easily way to build Eloquent queries from API requests.

Ephraïm SEDDOR 1 Nov 22, 2021
Fast and simple implementation of a REST API based on the Laravel Framework, Repository Pattern, Eloquent Resources, Translatability, and Swagger.

Laravel Headless What about? This allows a fast and simple implementation of a REST API based on the Laravel Framework, Repository Pattern, Eloquent R

Julien SCHMITT 6 Dec 30, 2022
A lightweight domain event pattern implementation for Doctrine2.

Knp Rad Domain Event A lightweight domain event pattern implementation for Doctrine2. Official maintainers: @Einenlum Installation With composer : $ c

KNP Labs 5 Sep 23, 2022
A package to implement repository pattern for laravel models

Laravel Model UUID A simple package to use Repository Pattern approach for laravel models . Repository pattern Repositories are classes or components

null 26 Dec 21, 2022
Auto-generated Interface and Repository file via Repository pattern in Laravel

Auto-generated Repository Pattern in Laravel A repository is a separation between a domain and a persistent layer. The repository provides a collectio

Ngo Dinh Cuong 11 Aug 15, 2022
Laravel Design Pattern Generator (api generator)

Laravel Design Pattern Generator (api generator) you can create your restful api easily by using this library and you can filter, sort and include elo

HusseinAlaa 2 Sep 25, 2022
🖖Repository Pattern in Laravel. The package allows to filter by request out-of-the-box, as well as to integrate customized criteria and any kind of filters.

Repository Repository Pattern in Laravel. The package allows to filter by request out-of-the-box, as well as to integrate customized criteria and any

Awes.io 160 Dec 26, 2022
Laravel specification pattern

Laravel specification pattern Filter an Illuminate collection with specifications. Installation You can install the package via composer: composer req

Maarten Paauw 5 Nov 30, 2022
Need some filters? This package is based on the Repository Design Pattern to let you create specific queries easily.

DevMakerLab/Laravel-Filters Need some filters? This package is based on the Repository Design Pattern to let you create specific queries easily. Insta

DevMakerLab 19 Feb 20, 2022
Twig-based PatternEngine for Pattern Lab.

Twig PatternEngine for Pattern Lab The Twig PatternEngine allows you to use Twig as the template language for Pattern Lab PHP. Once the PatternEngine

Pattern Lab 77 Oct 27, 2022
States allows you to create PHP classes following the State Pattern in PHP.

States allows you to create PHP classes following the State Pattern in PHP. This can be a cleaner way for an object to change its behavior at runtime without resorting to large monolithic conditional statements and this improve maintainability and workflows writing.

Teknoo Software 10 Nov 20, 2022
Implementation Package Spatie/Laravel-Permission

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

M Rizal 3 Sep 12, 2021
A lightway implementation of Laravel's belongs To many

A lightweigth implementation of Laravel's belongs To many relationship in cases you don't need pivot table.

Inani El Houssain 24 Nov 2, 2022
A simple Socialite implementation for Laravel Jetstream.

Introduction Socialstream is a third-party package for Laravel Jetstream. It replaces the published authentication and profile scaffolding provided by

Joel Butcher 334 Jan 2, 2023
An easy-to-use virtual wallet implementation for Laravel

Laravel Wallet Some apps require a prepayment system like a virtual wallet where customers can recharge credits which they can then use to pay in app

Muath Assawadi 6 Sep 28, 2022
A Gutenberg implementation for Laravel

Laraberg aims to provide an easy way to integrate the Gutenberg editor with your Laravel projects. It takes the Gutenberg editor and adds all the comm

Van Ons Internet Agency 1.2k Dec 22, 2022
Easy Laravel Server-Side implementation of PrimeVue Datatables

Laravel + PrimeVue Datatables This is a simple, clean and fluent serve-side implementation of PrimeVue Datatables in Laravel. Features Global Search i

Savannabits 11 Dec 29, 2022
🍩 SweetAlert 2 Implementation for Laravel

?? SweetAlert2 Support for Laravel Add beautiful alerts by SweetAlert directly into your Laravel application, with a simple setup, and handly helpers.

Wavey 38 Dec 12, 2022
An easy-to-use virtual wallet implementation for Laravel.

Laravel Wallet Some apps require a prepayment system like a virtual wallet where customers can recharge credits which they can then use to pay in app

Muathye 1 Feb 6, 2022