use rsiot_messages_core::*;
use super::LineProtocolItem;
#[derive(Clone, Debug)]
pub struct Config<TMsg> {
pub host: String,
pub port: u16,
pub org: String,
pub bucket: String,
pub token: String,
pub fn_input: fn(&Message<TMsg>) -> Option<Vec<LineProtocolItem>>,
}
#[cfg(test)]
mod test {
use super::super::super::influxdb_v2 as cmp_influxdb;
#[test]
fn stub() {
use rsiot_messages_core::example_message::*;
let _ = cmp_influxdb::Config::<Custom> {
host: String::from("influxdb"),
port: 8086,
org: String::from("org"),
bucket: String::from("bucket"),
token: String::from("token"),
fn_input: |_| None,
};
}
#[test]
fn fn_input() {
use rsiot_messages_core::{example_message::*, *};
let _ = cmp_influxdb::Config::<Custom> {
host: String::from("influxdb"),
port: 8086,
org: String::from("org"),
bucket: String::from("bucket"),
token: String::from("token"),
fn_input: |msg: &Message<Custom>| {
let value = match &msg.data {
MsgData::Custom(Custom::ValueInstantF64(data)) => {
cmp_influxdb::ValueType::f64(*data)
}
_ => return None,
};
let line = cmp_influxdb::LineProtocolItem::new(&msg.key, value, &msg.ts);
Some(vec![line])
},
};
}
}