emergency_brake

Crates.ioemergency_brake
lib.rsemergency_brake
version0.1.0
sourcesrc
created_at2023-09-25 02:31:27.496103
updated_at2023-09-25 02:31:27.496103
descriptionemergency_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.
homepagehttps://github.com/TrippingKelsea/EmergencyBrake
repositoryhttps://github.com/TrippingKelsea/EmergencyBrake
max_upload_size
id982298
size15,087
Kelsea (TrippingKelsea)

documentation

https://github.com/TrippingKelsea/EmergencyBrake

README

Emergency Brake

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.

Usage

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 sample_window_size = 25;
    let threshold = 3;
    let mut ebrake = EBrake::new(sample_window_size, threshold);
    loop:
        // Check service status
        let service_status: bool = check_service_status('service.foo.com');
        // Add the sample to the sample window and trigger if necessary
        ebrake.add_sample(service_status);
        ebrake.trigger();
        // Do something critical
        ...
}
Commit count: 18

cargo fmt