Crate service_probe

Crate service_probe 

Source
Expand description

§Service probe

This crate provides an easy way to start a HTTP server that can be used for making the status of a service transparent to observers. The main use case is to communicate information about the health status of a service in containerized environments.

Tasks and synchronization throughout this crate uses tokio functionality, so the runtime must be present and running when the functions of this crate are called.

To start the service probe, add the following code to your service:

use service_probe::{start_probe, ServiceState, set_service_state};

// The probe server is started in the background. Up signals that the services is starting.
start_probe([0u8, 0, 0, 0], 11333, ServiceState::Up).await.unwrap();

// If everything is ready, we set the state to ready.
set_service_state(ServiceState::Ready);

Enums§

ProbeStartError
The error that can happen during startup of the service probe.
ServiceState
The state of a service

Constants§

SHUTDOWN_GRACE_PERIOD
The grace period given to the probe for shutting itself down.

Functions§

get_service_state
Get the state of the service.
set_service_state
Set the state of the service.
start_probe
Start the probe HTTP service.
stop_probe
Stop the probe HTTP service.