From 83516e5fbc9df22e9362c41a0af4b8531b707b0a Mon Sep 17 00:00:00 2001 From: prplV Date: Fri, 7 Mar 2025 10:53:20 +0300 Subject: [PATCH] endpoints comments --- src/endpoints.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/endpoints.rs b/src/endpoints.rs index f1538eb..4a3e2a5 100644 --- a/src/endpoints.rs +++ b/src/endpoints.rs @@ -10,6 +10,17 @@ use crate::AppState; use tracing::{ error, info, warn }; use crate::metrics::{MetricsProcesser, MetricsValueType}; +/// An `Update` endpoint +/// +/// Used to registrate new metrics and to update already +/// existing in local metrics `Registry` +/// +/// # Usage +/// +/// ``` bash +/// curl -X POST -d '"id" : ...' 'http::/localhost:9100/update' +/// ``` +/// pub async fn update_metrics( State(state): State>, Json(request) : Json> @@ -59,6 +70,17 @@ pub async fn update_metrics( (http::StatusCode::ACCEPTED, "Ok") } +/// An `Metrics` endpoint +/// +/// Needed in sharing current local metrics `Registry` state +/// and all stored metrics +/// +/// # Usage +/// +/// ``` bash +/// curl -X GET 'http::/localhost:9100/metrics' +/// ``` +/// pub async fn metrics_handler(State(state): State>) -> String { let registry = state.registry.lock(); @@ -76,6 +98,11 @@ pub async fn metrics_handler(State(state): State>) -> String { } } +/// A function-registrator +/// +/// Registrates or updates metrics state in local +/// `Registry` +/// pub fn update_or_insert_metric<'a>( metric: Gauge, registry: MutexGuard<'a, Registry>,