Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sovereign-intelligence/blob/main/docs/archive/drakestapleton.com-old/crates/site-server/src/routes/stream.rs # sovereign-intelligence Front door to Drake Stapleton's sovereign stack. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `sovereign-intelligence / docs / archive / drakestapleton.com-old / crates / site-server / src / routes / stream.rs` 31 lines ยท 969 bytes Raw Blame History 1 use axum::{ 2 extract::State, 3 response::{ 4 sse::{Event, KeepAlive, Sse}, 5 Json, 6 }, 7 }; 8 use futures_util::stream::Stream; 9 use std::convert::Infallible; 10 use std::time::Duration; 11 use crate::state::AppState; 12 use crate::telemetry::TelemetryPacket; 13 14 pub async fn get_telemetry(State(state): State) -> Json { 15 let current = state.latest_telemetry.read().await.clone(); 16 Json(current) 17 } 18 19 pub async fn stream_telemetry( 20 State(state): State, 21 ) -> Sse>> { 22 let mut rx = state.telemetry_tx.subscribe(); 23 let stream = async_stream::stream! { 24 while let Ok(packet) = rx.recv().await { 25 let json_str = serde_json::to_string(&packet).unwrap_or_default(); 26 yield Ok(Event::default().event("telemetry").data(json_str)); 27 } 28 }; 29 30 Sse::new(stream).keep_alive(KeepAlive::new().interval(Duration::from_secs(15)).text("ping")) 31 }