Compare commits
3 Commits
ba82d59c74
...
96dc94bf0b
| Author | SHA1 | Date |
|---|---|---|
|
|
96dc94bf0b | |
|
|
5e8eadac9b | |
|
|
f6ad632c2d |
|
|
@ -5,6 +5,7 @@ use tokio_postgres::NoTls;
|
||||||
use std::env;
|
use std::env;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use log::{info, error};
|
use log::{info, error};
|
||||||
|
use std::ops::Drop;
|
||||||
|
|
||||||
/// An entity which handles DB connections.
|
/// An entity which handles DB connections.
|
||||||
///
|
///
|
||||||
|
|
@ -102,3 +103,9 @@ impl Exporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for Exporter {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
info!("Deinitializng Exporter and DB connection pool ...")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,21 @@
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use integr_structs::api::v3::{Metric, MetricOutput};
|
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;
|
pub struct JsonParser;
|
||||||
|
|
||||||
impl JsonParser {
|
impl JsonParser {
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,16 @@ pub mod v3 {
|
||||||
pub json_type : String,
|
pub json_type : String,
|
||||||
pub addr : 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)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct Metrics {
|
pub struct Metrics {
|
||||||
pub name : String,
|
pub name : String,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue