Browse Source

DetectionRunner++

anomly-detector-configurable-iteration-steps-#35
Alexey Velikiy 2 years ago
parent
commit
07a58dde02
  1. 1
      server/src/services/analytic_service/analytic_service.rs
  2. 8
      server/src/services/analytic_service/detection_runner.rs
  3. 1
      server/src/services/analytic_service/types.rs

1
server/src/services/analytic_service/analytic_service.rs

@ -265,7 +265,6 @@ impl AnalyticService {
pub async fn serve(&mut self) {
// TODO: remove this hack
self.consume_request(RequestType::RunLearning);
// TODO: start detection runner if
if self.alerting.is_some() {
self.run_detection_runner();
}

8
server/src/services/analytic_service/detection_runner.rs

@ -26,20 +26,23 @@ impl DetectionRunner {
pub async fn run(&mut self, from: u64) {
// TODO: get last detection timestamp from persistance
// TODO: set lst detection from "now"
// TODO: set last detection from "now"
if self.running_handler.is_some() {
self.running_handler.as_mut().unwrap().abort();
}
self.running_handler = Some(tokio::spawn({
// TODO: clone channel
let cfg = self.config.clone();
async move {
// AnalyticService::run_learning(tx, cfg, ms, ss).await;
// TODO: run detection "from"
// TODO: define window for detection
loop {
// TODO: run detection periodically
// TODO: use interval
sleep(Duration::from_secs(100)).await;
// TODO: sell to config
sleep(Duration::from_secs(cfg.interval)).await;
}
}
}));
@ -48,5 +51,6 @@ impl DetectionRunner {
pub async fn set_analytic_unit(
analytic_unit: Arc<RwLock<Box<dyn AnalyticUnit + Send + Sync>>>,
) {
// TODO: implement
}
}

1
server/src/services/analytic_service/types.rs

@ -97,6 +97,7 @@ pub struct DetectionRunnerConfig {
// pub sender: mpsc::Sender<Result<Vec<Segment>>>,
pub endpoint: String,
pub from: u64,
pub interval: u64
}
#[derive(Debug)]

Loading…
Cancel
Save