#service #http-service #probe #state #health #querying

service-probe

Probe for querying service state through a minimal HTTP service

4 releases

new 0.2.0 Dec 11, 2024
0.1.2 Nov 28, 2024
0.1.1 Nov 20, 2024
0.1.0 Nov 19, 2024

#191 in HTTP server

Download history 446/week @ 2024-11-19 401/week @ 2024-11-26 491/week @ 2024-12-03 851/week @ 2024-12-10

2,189 downloads per month

MIT/Apache

13KB
158 lines

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.

The "main" service does not need to provide a HTTP server on its own, the probe will spin up its own minimalistic HTTP server.


lib.rs:

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);

Dependencies

~5–13MB
~162K SLoC