fix(sse): tune broadcast capacity and recover lagged subscribers #58
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_router!58
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_sse_buffer_resync"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Makes the SSE broadcast channel capacity tunable and stops the dashboard from silently going stale when a subscriber falls behind.
Related Issue
Closes #51
Changes
crates/hero_router/src/config.rs: new env varROUTER_SSE_BUFFER(default 1024, must be > 0); newRouterConfig.sse_bufferfield and.sse_buffer(usize)builder; tests extended.crates/hero_router/src/main.rs:SseBroadcaster::new(64)->SseBroadcaster::new(cfg.sse_buffer).crates/hero_router/src/server/sse.rs: doc comment onSseBroadcaster::newdocuments the env var, the lagged-subscriber semantics, and theresyncrecovery path.crates/hero_router/src/server/routes.rs:sse_handlerno longer silently dropsErr(_)via.ok().BroadcastStreamRecvError::Lagged(n)now emitstracing::warn!and yieldsevent: resync\ndata: {"dropped":n}\n\n. Closed channel still terminates the stream cleanly.crates/hero_router/static/js/dashboard.js:initSSE()registers aresynclistener that logs the drop count and calls the existing idempotentreloadSidebar().Test Results
cargo test -p hero_router-- 71 passed, 0 failed.cargo build -p hero_routerclean.Notes
String, so worst-case memory is well under a MiB.BroadcastStreamRecvErrorcurrently has onlyLagged(u64)intokio-stream 0.1; closed channels are signalled byNonefrom the stream wrapper. Match is exhaustive today; future variants will surface as a compile error -- intentional.Pull request closed