Skip to main content

relay_core_runtime/services/
status.rs

1use async_trait::async_trait;
2use tokio::sync::watch;
3use crate::{CoreMetrics, CoreState, CoreStatusReport, CoreStatusSnapshot, RuntimeLifecycle};
4
5#[async_trait]
6pub trait RuntimeStatusService: Send + Sync {
7    fn status_snapshot(&self) -> CoreStatusSnapshot;
8    async fn status_report(&self) -> CoreStatusReport;
9    async fn get_metrics(&self) -> CoreMetrics;
10    async fn get_metrics_prometheus_text(&self) -> String;
11    fn subscribe_lifecycle(&self) -> watch::Receiver<RuntimeLifecycle>;
12}
13
14#[async_trait]
15impl RuntimeStatusService for CoreState {
16    fn status_snapshot(&self) -> CoreStatusSnapshot {
17        CoreState::status_snapshot(self)
18    }
19
20    async fn status_report(&self) -> CoreStatusReport {
21        CoreState::status_report(self).await
22    }
23
24    async fn get_metrics(&self) -> CoreMetrics {
25        CoreState::get_metrics(self).await
26    }
27
28    async fn get_metrics_prometheus_text(&self) -> String {
29        CoreState::get_metrics_prometheus_text(self).await
30    }
31
32    fn subscribe_lifecycle(&self) -> watch::Receiver<RuntimeLifecycle> {
33        CoreState::subscribe_lifecycle(self)
34    }
35}