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