Crius
Crius is a simple hystrix-like circuit breaker for rust.
"In the midst of chaos, there is also opportunity"
Usage
Simple command
use ;
;
// Define a simple circuit breaker command:
let mut cmd = command.unwrap;
// and run it with an example input:
let result = cmd.run;
assert_eq!;
Command with fallback
use ;
;
let double_if_lt_ten = ;
// Define a simple circuit breaker command:
let mut cmd = command_with_fallback.unwrap;
// and run it with an example input:
let result = cmd.run;
assert_eq!;
Command with custom configuration
use ;
let config = * default
.circuit_open_ms
.error_threshold
.error_threshold_percentage
.buckets_in_window
.bucket_size_in_ms;
let mut cmd = command.unwrap;
// and run it with an example input:
let result = cmd.run;
assert_eq!;
Configuration
circuit_open_ms
- Time in ms commands are rejected after the circuit opened - Default 5000
error_threshold
- Minimum amount of errors for the circuit to break - Default 10
error_threshold_percentage
- Minimum error percentage for the circuit to break - Default 50
buckets_in_window
- Rolling window to track success/error calls, this property defines the amount of buckets in a window (buckets_in_window * bucket_size_in_ms is the overall length in ms of the window) - Default 10
bucket_size_in_ms
- This property defines the ms a bucket is long, i.e. each x ms a new bucket will be created (buckets_in_window * bucket_size_in_ms is the overall length in ms of the window) - Default 1000
circuit_breaker_enabled
- Defines if the circuit breaker is enabled or not - Default true