valensas_actuator/
lib.rs

1//! # Valensas Actuator
2//!
3//! This library provides facilities for web server lifecycle operations.
4//!
5//! Features:
6//!
7//! - Health checks: liveness and readiness
8//!
9//!   - [Diesel](https://github.com/diesel-rs/diesel) health
10//!
11//!   - [Tonic Health](https://github.com/hyperium/tonic/tree/master/tonic-health)
12//!
13//!   - Customizable indicators
14//!
15//! - [Prometheus](http://prometheus.io) metric collection
16//!
17//!   - Rocket http request metrics
18//!
19//!   - Tonic grpc request metrics
20//!
21//!   - r2d2 connection pool metrics
22//!
23//!   - Tokio runtime metrics
24//!
25//!
26//! ## Installation
27//!
28//! Add the following to your `Cargo.toml`:
29//!
30//! ```toml
31//! [dependencies]
32//! valensas-actuator = "*"
33//! ```
34//!
35//! ## Features
36//!
37//! The following crate features are available to use:
38//!
39//! health: includes health check related functionalities
40//!
41//! health-tonic: includes tonic-health health indicator
42//!
43//! health-diesel: includes diesel health indicator
44//!
45//! promtheteus-rocket: includes Prometheus scrap endpoint and Rocket http request metric collection
46//!
47//! prometheus-tonic: includes Tonic grpc request metric collection
48//!
49//! prometheus-r2d2: includes r2d2 connection pool metrics collection
50//!
51//! ## Examples
52//!
53//! For detailed usage examples, see the examples directory.
54//!
55//!
56//! ### health.rs
57//!
58//! Contains examples on how to configure health check endpoints and custom health indicators.
59//!
60//! Run with `cargo run --example health --features health,health-diesel`.
61//!
62//! ### prometheus.rs
63//!
64//! Contains examples on how to configure Prometheus scrap endpoint and Rocket request metric collection.
65//!
66//! Run with `cargo run --example prometheus --features prometheus-rocket`.
67//!
68//! ### prometheus_tonic.rs
69//!
70//! Contains examples on how to configure Prometheus scrap endpoint and Tonic gRPC request metric collection.
71//!
72//! Run with `cargo run --example prometheus_tonic --features prometheus-tonic`.
73//!
74//! ### prometheus_r2d2.rs
75//!
76//! Contains examples on how to configure the r2d2 connection pool collector to expose pool usage metrics.
77//!
78//! Run with `cargo run --example prometheus_r2d2 --features prometheus-r2d2`
79//!
80//! ### prometheus_tokio.rs
81//!
82//! Contains examples on how to configure the Tokio runtime pool collector to expose runtime usage metrics.
83//!
84
85use rocket::{Build, Rocket};
86
87pub mod actuator;
88
89#[cfg(feature = "health")]
90pub mod health;
91
92#[cfg(feature = "prometheus-rocket")]
93pub mod prometheus;
94
95pub struct Actuator {
96    rocket: Rocket<Build>,
97}
98
99pub fn actuate(rocket: rocket::Rocket<Build>) -> Actuator {
100    Actuator::new(rocket)
101}