First step toward supporting multiple database writes

This commit is contained in:
2021-08-31 17:29:26 -07:00
parent aefd8cde25
commit c88858e43f
3 changed files with 62 additions and 50 deletions

View File

@ -45,20 +45,22 @@ pub struct UserAuth {
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InfluxDBConfig {
pub url: String,
pub auth: Option<UserAuth>,
pub db_name: String,
pub measurement: String,
#[serde(rename_all = "kebab-case", tag = "type")]
pub enum Database {
#[serde(rename_all = "camelCase")]
Influxdb {
url: String,
auth: Option<UserAuth>,
db_name: String,
measurement: String,
},
}
#[derive(Debug, Deserialize, Clone)]
#[serde(rename_all = "camelCase", tag = "type")]
#[allow(non_camel_case_types)]
#[serde(rename_all = "kebab-case", tag = "type")]
pub enum Payload {
#[serde(rename_all = "camelCase")]
json {
Json {
value_field_path: String,
timestamp_field_path: Option<String>,
},
@ -79,7 +81,7 @@ pub struct Mapping {
pub struct Config {
pub log_level: Option<LevelFilter>,
pub mqtt: MqttConfig,
pub database: InfluxDBConfig,
pub databases: Vec<Database>,
pub mappings: Vec<Mapping>,
}