mirror of
https://codeberg.org/icewind/prometheus-edge-trigger.git
synced 2026-06-03 18:24:10 +02:00
move delay option into trigger root
This commit is contained in:
parent
fe92c27bc6
commit
8a7f023631
4 changed files with 4 additions and 4 deletions
0
README.md
Normal file
0
README.md
Normal 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\"}"
|
||||||
|
|
@ -14,4 +15,3 @@ params.instance = { type = "mdns", service = "_switch-http._tcp.local", host = "
|
||||||
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
|
|
||||||
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue