leocarmo / Circuit Breaker Php
Circuit Breaker Pattern for PHP
Stars: ✭ 202
Labels
Projects that are alternatives of or similar to Circuit Breaker Php
Guard
NOT MAINTAINED! A generic high performance circuit breaker & proxy server written in Go
Stars: ✭ 745 (+268.81%)
Mutual labels: circuit-breaker
Rezilience
ZIO-native utilities for making resilient distributed systems
Stars: ✭ 60 (-70.3%)
Mutual labels: circuit-breaker
Circuitbreaker
.NET Circuit Breaker Pattern Frameworks
Stars: ✭ 122 (-39.6%)
Mutual labels: circuit-breaker
Sample Camel Spring Boot
three samples in different branches that illustrates usage of apache camel as microservice framework providing integration with consul, hystrix, ribbon and other tools
Stars: ✭ 24 (-88.12%)
Mutual labels: circuit-breaker
Recloser
A concurrent circuit breaker implemented with ring buffers
Stars: ✭ 51 (-74.75%)
Mutual labels: circuit-breaker
Polly
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+.
Stars: ✭ 9,944 (+4822.77%)
Mutual labels: circuit-breaker
Steeltoe
Steeltoe .NET Core Components: CircuitBreaker, Configuration, Connectors, Discovery, Logging, Management, and Security
Stars: ✭ 612 (+202.97%)
Mutual labels: circuit-breaker
Tree Gateway
This is a full featured and free API Gateway
Stars: ✭ 160 (-20.79%)
Mutual labels: circuit-breaker
Circuit Breaker Monad
Circuit Breaker pattern as a monad
Stars: ✭ 52 (-74.26%)
Mutual labels: circuit-breaker
Failsafe Rs
A circuit breaker implementation for rust
Stars: ✭ 118 (-41.58%)
Mutual labels: circuit-breaker
Breaker
Circuit breaker for HTTP requests in Elixir
Stars: ✭ 30 (-85.15%)
Mutual labels: circuit-breaker
Cockatiel
A resilience and transient-fault-handling library that allows developers to express policies such as Backoff, Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback. Inspired by .NET Polly.
Stars: ✭ 993 (+391.58%)
Mutual labels: circuit-breaker
Circuit B
A non intrusive circuit breaker for node.js
Stars: ✭ 88 (-56.44%)
Mutual labels: circuit-breaker
Luffy
Luffy is a simple resilience and transient-fault handling library
Stars: ✭ 19 (-90.59%)
Mutual labels: circuit-breaker
Istio
Connect, secure, control, and observe services.
Stars: ✭ 28,970 (+14241.58%)
Mutual labels: circuit-breaker
Go Chassis
a microservice framework for rapid development of micro services in Go with rich eco-system
Stars: ✭ 2,428 (+1101.98%)
Mutual labels: circuit-breaker
Safely
Safely is a Clojure's circuit-breaker library for handling retries in an elegant declarative way.
Stars: ✭ 152 (-24.75%)
Mutual labels: circuit-breaker
PHP implementation of Circuit Breaker Pattern
For more information about this pattern see this.
This implementation has only redis adapter yet
Starting with composer
composer require leocarmo/circuit-breaker-php
Redis adapter
The first argument is a redis connection, the second is your product name, for redis namespace avoid key conflicts with another product using the same redis.
use LeoCarmo\CircuitBreaker\CircuitBreaker;
// Connect to redis
$redis = new \Redis();
$redis->connect('localhost', 6379);
$adapter = new \LeoCarmo\CircuitBreaker\Adapters\RedisAdapter($redis, 'my-product');
// Set redis adapter for CB
CircuitBreaker::setAdapter($adapter);
Set circuit break settings
This is not required, default values will be set
// Configure settings for CB
CircuitBreaker::setGlobalSettings([
'timeWindow' => 60, // Time for an open circuit (seconds)
'failureRateThreshold' => 50, // Fail rate for open the circuit
'intervalToHalfOpen' => 30, // Half open time (seconds)
]);
Configure settings for specific service
// Configure settings for specific service
CircuitBreaker::setServiceSettings('my-custom-service', [
'timeWindow' => 30, // Time for an open circuit (seconds)
'failureRateThreshold' => 15, // Fail rate for open the circuit
'intervalToHalfOpen' => 10, // Half open time (seconds)
]);
Check if circuit is available (closed)
Each check is for a specific service. So you can have multiple services in the same application, and when one circuit is open, the other works normally.
// Check circuit status for service: `my-service`
if (! CircuitBreaker::isAvailable('my-service')) {
die('Circuit is not available!');
}
Record success and failure
// Usage example for success and failure
try {
Service::execute('something');
CircuitBreaker::success('my-service');
} catch (\ServiceException $e) {
CircuitBreaker::failure('my-service');
die($e->getMessage());
}
Credits
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].