Browse Source

runner begin

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
3cd793f588
  1. 16
      server/src/services/analytic_service/analytic_service.rs
  2. 9
      server/src/services/analytic_service/types.rs

16
server/src/services/analytic_service/analytic_service.rs

@ -1,4 +1,4 @@
use super::types;
use super::types::{self, DetectionRunnerConfig};
use super::{
analytic_client::AnalyticClient,
pattern_detector::{self, LearningResults, PatternDetector},
@ -76,6 +76,17 @@ impl AnalyticService {
});
}
fn run_detection_runner(&self, task: DetectionRunnerConfig) {
// TODO: save handler of the task
tokio::spawn({
let lr = self.learning_results.as_ref().unwrap().clone();
let ms = self.metric_service.clone();
async move {
}
});
}
fn consume_request(&mut self, req: types::RequestType) -> () {
match req {
RequestType::RunLearning => {
@ -100,8 +111,9 @@ impl AnalyticService {
.send(Err(anyhow::format_err!("Analytics in initialization")))
{
Ok(_) => {}
Err(e_) => {
Err(e) => {
println!("failed to send error about initialization");
println!("{:?}", e);
}
}
return;

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

@ -4,7 +4,7 @@ use super::pattern_detector::LearningResults;
use anyhow::Result;
use serde::Serialize;
use tokio::sync::oneshot;
use tokio::sync::{mpsc, oneshot};
#[derive(Debug, Clone, PartialEq, Serialize)]
pub enum LearningStatus {
@ -30,6 +30,13 @@ pub struct DetectionTask {
pub to: u64,
}
#[derive(Debug)]
pub struct DetectionRunnerConfig {
pub sender: mpsc::Sender<Result<Vec<Segment>>>,
pub endpoint: String,
pub from: u64
}
#[derive(Debug)]
pub enum RequestType {
// TODO: convert to result RunLearning(anyhow::Result<()>)

Loading…
Cancel
Save