Compare commits

...

3 Commits

Author SHA1 Message Date
prplV 96dc94bf0b added json doc-comment
test-org/integration-module/pipeline/pr-rc This commit looks good Details
2025-03-05 13:40:41 +03:00
prplV 5e8eadac9b Metric template tempo added 2025-03-05 13:32:55 +03:00
prplV f6ad632c2d desctruct info for exporter 2025-03-05 13:26:56 +03:00
3 changed files with 32 additions and 0 deletions

View File

@ -5,6 +5,7 @@ use tokio_postgres::NoTls;
use std::env;
use anyhow::Result;
use log::{info, error};
use std::ops::Drop;
/// An entity which handles DB connections.
///
@ -101,4 +102,10 @@ impl Exporter {
Ok(metrics.get_bytes_len())
}
}
impl Drop for Exporter {
fn drop(&mut self) {
info!("Deinitializng Exporter and DB connection pool ...")
}
}

View File

@ -2,6 +2,21 @@
use serde_json::{json, Value};
use integr_structs::api::v3::{Metric, MetricOutput};
/// A JSON-parser struct
///
/// Using in metric extracting from Server Response
/// with metrics mechanism
///
/// # Example
///
/// ```
/// use api-grub::json::JsonParser;
/// use use integr_structs::api::v3::Metric;
///
/// let json = b""flat1" : { "room1" : { "rt_tempo" : "+16" }}".to_vec();
///
/// assert!(!JsonParser::parse(vec![Metric::template()], json).is_empty());
/// ```
pub struct JsonParser;
impl JsonParser {

View File

@ -160,6 +160,16 @@ pub mod v3 {
pub json_type : String,
pub addr : String,
}
impl Metric {
pub fn template() -> Self {
Self {
id : "room_tempo".to_string(),
json_type : "String".to_string(),
addr : "flat1.room1.rt_tempo".to_string(),
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Metrics {
pub name : String,