Browse Source

Merge pull request #108 from hastic/get-notified-in-analytic-service-about-new-detections-#51

detection runner detection notification
main
glitch4347 2 years ago committed by GitHub
parent
commit
aa4008662a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      server/src/services/analytic_service/analytic_service.rs
  2. 10
      server/src/services/analytic_service/detection_runner.rs
  3. 1
      server/src/services/analytic_service/types.rs

3
server/src/services/analytic_service/analytic_service.rs

@ -245,6 +245,9 @@ impl AnalyticService {
.set_last_detection(id, timestamp)
.unwrap();
}
ResponseType::DetectionRunnerDetection(from, to) => {
println!("detection: {} {}", from, to);
}
ResponseType::LearningStarted => {
self.analytic_unit_learning_status = LearningStatus::Learning
}

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

@ -69,7 +69,15 @@ impl DetectionRunner {
let detections = a.detect(ms.clone(), t_from, t_to).await.unwrap();
for d in detections {
println!("detection: {} {}", d.0, d.1);
match tx
.send(AnalyticServiceMessage::Response(Ok(
ResponseType::DetectionRunnerDetection(d.0, d.1),
)))
.await
{
Ok(_) => {}
Err(_e) => println!("Fail to send detection runner detection notification"),
}
}
// TODO: send info about detections to tx

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

@ -45,6 +45,7 @@ impl Default for LearningTrain {
pub enum ResponseType {
DetectionRunnerStarted(u64),
DetectionRunnerUpdate(String, u64), // analytic_unit id and timestamp
DetectionRunnerDetection(u64, u64), // TODO: add more into about analytic unit and more
LearningStarted,
LearningFinished(Box<dyn AnalyticUnit + Send + Sync>),
LearningFinishedEmpty,

Loading…
Cancel
Save