Server tools to backfill, tail, mirror, and verify PLC logs
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

mirror: print backend used

geesawra 8474087c 1c879068

+23 -12
+2 -5
src/bin/mirror.rs
··· 1 1 use allegedly::{ 2 - DatastoreEnum, Db, ExperimentalConf, ListenConf, RocksDatastore, 3 - bin::GlobalArgs, 4 - bin_init, 5 - datastore::{Datastore, SendDatastore}, 6 - poll_upstream, serve, 2 + DatastoreEnum, Db, ExperimentalConf, ListenConf, RocksDatastore, bin::GlobalArgs, bin_init, 3 + datastore::Datastore, poll_upstream, serve, 7 4 }; 8 5 use anyhow::anyhow; 9 6 use clap::Parser;
+21 -7
src/mirror.rs
··· 27 27 /// server info that only applies in mirror (synchronizing) mode 28 28 #[derive(Clone)] 29 29 struct SyncInfo { 30 + backend: String, 30 31 latest_at: CachedValue<Dt, GetLatestAt>, 31 32 upstream_status: CachedValue<PlcStatus, CheckUpstream>, 32 33 } ··· 53 54 54 55 {upstream} 55 56 56 - "# 57 + Configured storage backend: 58 + 59 + {}"#, 60 + sync_info.as_ref().unwrap().backend 57 61 ) 58 62 } else { 59 63 format!( ··· 217 221 if let Some(SyncInfo { 218 222 latest_at, 219 223 upstream_status, 224 + backend, 220 225 }) = sync_info 221 226 { 222 227 // mirror mode ··· 230 235 Json(serde_json::json!({ 231 236 "server": "allegedly (mirror)", 232 237 "version": env!("CARGO_PKG_VERSION"), 238 + "backend": backend, 233 239 "wrapped_plc": wrapped_status, 234 240 "upstream_plc": upstream_status, 235 241 "latest_at": latest, ··· 401 407 .expect("reqwest client to build"); 402 408 403 409 // when `db` is None, we're running in wrap mode. no db access, no upstream sync 404 - let sync_info = db.map(|db| SyncInfo { 405 - latest_at: CachedValue::new(GetLatestAt(db), Duration::from_secs(2)), 406 - upstream_status: CachedValue::new( 407 - CheckUpstream(upstream.clone(), client.clone()), 408 - Duration::from_secs(6), 409 - ), 410 + let sync_info = db.map(|db| { 411 + let backend = match db { 412 + DatastoreEnum::Pg(_) => "postgres".to_owned(), 413 + DatastoreEnum::Rocks(_) => "rocksdb".to_owned(), 414 + }; 415 + 416 + SyncInfo { 417 + latest_at: CachedValue::new(GetLatestAt(db), Duration::from_secs(2)), 418 + upstream_status: CachedValue::new( 419 + CheckUpstream(upstream.clone(), client.clone()), 420 + Duration::from_secs(6), 421 + ), 422 + backend, 423 + } 410 424 }); 411 425 412 426 let state = State {