mirror of
https://github.com/spartanz51/tutabridge.git
synced 2026-06-24 10:54:32 +02:00
Log WS state transitions in production
The bridge already turns WsState changes into stats pulses for the UI but never logged the transition itself, so an INFO-only log stream had no record of reconnects. Track the previous state in the watcher and emit `info!` on each genuine transition (skipping duplicate sets from the same state — `publish()` is called a few times redundantly during the connect handshake). Picks up [[sdk]] commit 1036d6f2e5 (SDK heartbeat + idle timeout) via the submodule bump.
This commit is contained in:
@@ -290,13 +290,24 @@ impl BridgeHandle {
|
||||
let mut store_watch = store.subscribe();
|
||||
let mut ws_watch = bus_client.state();
|
||||
let mut shutdown_watch = shutdown_sync_rx.clone();
|
||||
// Track the previous WS state so we only log on transitions,
|
||||
// not on every internal `publish()` (some calls re-set the same
|
||||
// state).
|
||||
let mut last_ws_state = *ws_watch.borrow();
|
||||
tokio::spawn(async move {
|
||||
// Initial pulse so a subscriber sees the freshly-started state.
|
||||
let _ = stats_dirty.send(());
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = store_watch.changed() => { let _ = stats_dirty.send(()); }
|
||||
_ = ws_watch.changed() => { let _ = stats_dirty.send(()); }
|
||||
_ = ws_watch.changed() => {
|
||||
let now = *ws_watch.borrow();
|
||||
if now != last_ws_state {
|
||||
log::info!("ws state: {:?} → {:?}", last_ws_state, now);
|
||||
last_ws_state = now;
|
||||
}
|
||||
let _ = stats_dirty.send(());
|
||||
}
|
||||
_ = shutdown_watch.changed() => return,
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
Submodule tuta-repo updated: 6d31dec6f0...1036d6f2e5
Reference in New Issue
Block a user