[feat](trx-server): persist 24h decode history across restarts
Move persistent history from trx-client to trx-server where decode events originate. History for AIS, VDES, APRS, CW, FT8, and WSPR is loaded from ~/.local/cache/trx-rs/history.db at startup and flushed to disk every 60 seconds. CW events are now also stored in DecoderHistories and replayed to connecting clients, consistent with all other decoder types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -15,7 +15,6 @@ toml = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
dirs = "6"
|
||||
pickledb = "0.5"
|
||||
bytes = "1"
|
||||
cpal = "0.15"
|
||||
opus = "0.3"
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
mod audio_bridge;
|
||||
mod audio_client;
|
||||
mod config;
|
||||
mod history_store;
|
||||
mod remote_client;
|
||||
|
||||
use std::collections::HashMap;
|
||||
@@ -125,17 +124,6 @@ async fn async_init() -> DynResult<AppState> {
|
||||
let mut frontend_reg_ctx = FrontendRegistrationContext::new();
|
||||
let mut frontend_runtime = FrontendRuntimeContext::new();
|
||||
|
||||
// Load persisted decode history before frontends start.
|
||||
let db = {
|
||||
let db = history_store::open_db();
|
||||
history_store::load_all(&db, &mut frontend_runtime);
|
||||
tracing::info!(
|
||||
"Loaded decode history from {}",
|
||||
history_store::db_path().display()
|
||||
);
|
||||
std::sync::Arc::new(std::sync::Mutex::new(db))
|
||||
};
|
||||
|
||||
register_http_frontend(&mut frontend_reg_ctx);
|
||||
register_http_json_frontend(&mut frontend_reg_ctx);
|
||||
register_rigctl_frontend(&mut frontend_reg_ctx);
|
||||
@@ -349,9 +337,6 @@ async fn async_init() -> DynResult<AppState> {
|
||||
);
|
||||
}
|
||||
|
||||
// Flush in-memory history to disk every 60 seconds.
|
||||
history_store::spawn_flush_task(db.clone(), frontend_runtime_ctx.clone());
|
||||
|
||||
// Spawn frontends with runtime context
|
||||
for frontend in &frontends {
|
||||
let frontend_state_rx = state_rx.clone();
|
||||
|
||||
Reference in New Issue
Block a user