solution10/circuitbreaker

Simple circuitbreaker class that uses Doctrine\Cache to persist state

v1.2.0 2016-08-25 13:20 UTC

This package is not auto-updated.

Last update: 2024-04-10 23:25:21 UTC


README

Simple circuit breaker class.

Build Status Latest Stable Version Total Downloads License

Features

  • Adjustable thresholds
  • Adjustable cooldowns
  • Events on change
  • Any Doctine\Common\Cache\Cache implementation for persistence

Installation

Installation is via composer, in the usual manner:

$ composer require solution10/circuitbreaker

Example usage

<?php

$persistence = new \Doctrine\Common\Cache\ArrayCache();
$breaker = new \Solution10\CircuitBreaker\CircuitBreaker('my_backend_service', $persistence);

if ($breaker->isClosed()) {
    $response = doSomething();
    if ($response) {
        $breaker->success();
    } else {
        $breaker->failure();
    }
} else {
    gracefullyDegrade();
}

Userguide

Check out the Wiki

(or the /docs folder in the repo)

PHP Requirements

  • PHP >= 5.5

Author

Alex Gisby: GitHub, Twitter

License

MIT

Contributing

Contributors Notes