Alexey Velikiy
3 years ago
6 changed files with 47 additions and 49 deletions
@ -1,22 +1,11 @@
|
||||
use crate::{ |
||||
metric::Metric, |
||||
types::{DatasourceType, QueryConfig}, |
||||
}; |
||||
use crate::{metric::Metric, types::{DatasourceConfig}}; |
||||
|
||||
pub mod grafana; |
||||
pub mod prometheus; |
||||
|
||||
pub fn resolve(query_config: &QueryConfig) -> Box<dyn Metric + Sync> { |
||||
if query_config.datasource_type == DatasourceType::Grafana { |
||||
let gs = grafana::Grafana::new( |
||||
query_config.url.to_string(), |
||||
query_config.key.to_string(), |
||||
query_config.datasource_url.to_string(), |
||||
query_config.query.to_string(), |
||||
); |
||||
return Box::new(gs); |
||||
} else { |
||||
let pm = prometheus::Prometheus::new(&query_config.url, &query_config.query); |
||||
return Box::new(pm); |
||||
pub fn resolve(config: &DatasourceConfig) -> Box<dyn Metric + Sync> { |
||||
match config { |
||||
DatasourceConfig::Grafana(cfg) => Box::new(grafana::Grafana::new(cfg)), |
||||
DatasourceConfig::Prometheus(cfg) => Box::new(prometheus::Prometheus::new(cfg)) |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue