emergency_brake
is a simple and easy to use process or service monitor that will immediately
terminate the execution of a process or service on a critical dependency failure.
eBrake creates a moving sample window of the last N samples. If the number of failures in the sample window exceeds the threshold, the process or service will be terminated. The sample window is a circular buffer, so the oldest sample will be replaced by the newest sample.
``` use emergency_brake::*;
fn main() { let samplewindowsize = 25; let threshold = 3; let mut ebrake = EBrake::new(samplewindowsize, threshold); loop: // Check service status let servicestatus: bool = checkservicestatus('service.foo.com'); // Add the sample to the sample window and trigger if necessary ebrake.addsample(service_status); ebrake.trigger(); // Do something critical ... } ```