Skip to content

Commit

Permalink
broker2http - increase tokio::broadcast::channel capacity to try hand…
Browse files Browse the repository at this point in the history
…ling receiver lags

Signed-off-by: Lance-Drane <[email protected]>
  • Loading branch information
Lance-Drane committed Sep 30, 2024
1 parent 49a03e8 commit 7dbef63
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions broker-2-http/src/broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ impl Broadcaster {
/// Create the broadcaster. Note that it automatically wraps it in an Arc.
/// The broadcaster manages its producer but does not manage its consumers
pub fn new() -> Arc<Self> {
// TODO may be able to get away with smaller capacity
let (tx, _) = broadcast::channel(1);
// use a fairly large channel capacity to account for potential receiver lags
let (tx, _) = broadcast::channel(256);
Arc::new(Broadcaster { fanout: tx })
}

Expand Down
1 change: 1 addition & 0 deletions broker-2-http/src/routes/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fn sse_response(
break;
},
// send the broadcast message to the client, and continue listening for more messages
// TODO figure out more robust mechanism to handle "lagged" errors from the receiver.
resp = rx.recv() => {
match resp {
Ok(event) => {
Expand Down

0 comments on commit 7dbef63

Please sign in to comment.