adds saving and loading history to and from disk

This commit is contained in:
2025-01-01 10:08:50 -05:00
parent dfd524ba19
commit 9136c5fd71
15 changed files with 602 additions and 146 deletions

View File

@@ -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)),
}
}

View File

@@ -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())