Skip to content

Instantly share code, notes, and snippets.

@andrioid
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrioid/2e284e26beff03e55d7f to your computer and use it in GitHub Desktop.
Save andrioid/2e284e26beff03e55d7f to your computer and use it in GitHub Desktop.
<?php
interface ICircuitBreakerStorage {
}
class CircuitBreaker {
/**
* StorageImplemntation should be a defined interface.
**/
public function __construct(ICircuitBreakerStorage $storageImplementation=null) {
if ($storageImplementation==null) {
// default engine
}
}
/**
* Check failure threshold, return a CircuitBreakerException if reached.
* Otherwise catch exceptions and store them. Run anonymous functions.
*
* Key identifies the service you're shielding. "Payment" could be an example.
*
**/
public function run($key, Callable $callback) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment