smokestack/main: use try_send() instead of hanging send()
This commit is contained in:
parent
52c5597459
commit
ee0382b15e
|
@ -183,8 +183,10 @@ impl Feed {
|
|||
})
|
||||
.filter_map(|event| async move {
|
||||
match serde_json::from_str(&event.data) {
|
||||
Ok(post) =>
|
||||
Some(post),
|
||||
Ok(post) => {
|
||||
drop(event);
|
||||
Some(post)
|
||||
},
|
||||
Err(e) => {
|
||||
log::error!("Error decoding stream data: {}", e);
|
||||
None
|
||||
|
|
|
@ -114,7 +114,7 @@ impl State {
|
|||
.collect::<Vec<_>>()
|
||||
};
|
||||
for tx in txs {
|
||||
let _ = tx.send(msg.clone()).await;
|
||||
let _ = tx.try_send(msg.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ struct Pipe {
|
|||
|
||||
impl Drop for Pipe {
|
||||
fn drop(&mut self) {
|
||||
log::trace!("drop pipe");
|
||||
log::info!("Consumer disconnected");
|
||||
let mut consumers = self.consumers.write().unwrap();
|
||||
consumers.remove(&self.id);
|
||||
}
|
||||
|
@ -176,7 +176,6 @@ async fn main() {
|
|||
let mut pipe = state.pipe();
|
||||
|
||||
tokio::spawn(async move {
|
||||
log::trace!("while...");
|
||||
while let Some(msg) = pipe.rx.recv().await {
|
||||
match socket.write_all(&msg[..]).await {
|
||||
Ok(_) => {}
|
||||
|
|
Loading…
Reference in New Issue