move delay option into trigger root

This commit is contained in:
Robin Appelman 2020-01-25 14:55:53 +01:00
commit 8a7f023631
4 changed files with 4 additions and 4 deletions

0
README.md Normal file
View file

View file

@ -3,6 +3,7 @@ url = "http://astoria:9291"
[[trigger]] [[trigger]]
name = "VR Charging" name = "VR Charging"
delay = 300
[trigger.condition] [trigger.condition]
query = "switch_state{instance=\"$instance\"}" query = "switch_state{instance=\"$instance\"}"
@ -13,5 +14,4 @@ params.instance = { type = "mdns", service = "_switch-http._tcp.local", host = "
[trigger.action] [trigger.action]
method = "PUT" method = "PUT"
params.host = { type = "mdns", service = "_switch-http._tcp.local", host = "vr_switch" } params.host = { type = "mdns", service = "_switch-http._tcp.local", host = "vr_switch" }
url = "http://$host/off" url = "http://$host/off"
delay = 300

View file

@ -54,7 +54,6 @@ pub struct Action {
pub method: Method, pub method: Method,
pub params: HashMap<String, Parameter>, pub params: HashMap<String, Parameter>,
pub url: String, pub url: String,
pub delay: u64,
} }
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
@ -72,6 +71,7 @@ pub struct PrometheusConfig {
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
pub struct Trigger { pub struct Trigger {
pub name: String, pub name: String,
pub delay: u64,
pub condition: Condition, pub condition: Condition,
pub action: Action, pub action: Action,
} }

View file

@ -53,7 +53,7 @@ impl TriggerManager {
} }
async fn run_trigger(&self, trigger: &Trigger) -> Result<(), MainError> { async fn run_trigger(&self, trigger: &Trigger) -> Result<(), MainError> {
let delay = trigger.action.delay; let delay = trigger.delay;
let delay_duration = Duration::from_secs(delay); let delay_duration = Duration::from_secs(delay);
let error_delay = Duration::from_secs(15); let error_delay = Duration::from_secs(15);
loop { loop {