adds saving and loading history to and from disk
This commit is contained in:
@@ -54,10 +54,11 @@ async fn get_tlm_history(
|
||||
};
|
||||
let maximum_resolution = TimeDelta::milliseconds(info.resolution);
|
||||
|
||||
let history_service = data.history_service();
|
||||
let data = data.pin();
|
||||
match data.get_by_uuid(&uuid) {
|
||||
None => Err(HttpServerResultError::TlmUuidNotFound { uuid }),
|
||||
Some(tlm) => Ok(web::Json(tlm.history.get(from, to, maximum_resolution))),
|
||||
Some(tlm) => Ok(web::Json(tlm.get(from, to, maximum_resolution, &history_service).await)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,19 +6,18 @@ use crate::http::api::setup_api;
|
||||
use crate::http::websocket::setup_websocket;
|
||||
use crate::telemetry::management_service::TelemetryManagementService;
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use log::trace;
|
||||
use std::error::Error;
|
||||
use log::info;
|
||||
use std::sync::Arc;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
pub async fn setup(
|
||||
cancellation_token: CancellationToken,
|
||||
telemetry_definitions: Arc<TelemetryManagementService>,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
) -> anyhow::Result<()> {
|
||||
let data = web::Data::new(telemetry_definitions);
|
||||
let cancel_token = web::Data::new(cancellation_token);
|
||||
|
||||
trace!("Starting HTTP Server");
|
||||
info!("Starting HTTP Server");
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.app_data(data.clone())
|
||||
|
||||
Reference in New Issue
Block a user