Skip to content

Commit c62ac2e

Browse files
committed
try faster send method in notification handler
1 parent c4fbfc5 commit c62ac2e

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

src/error.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ pub enum Error {
9595
#[error("Failed to perform HTTP request: {0}")]
9696
Reqwest(#[from] reqwest::Error),
9797

98-
/// Timeout while waiting for [`notify_loop()`](crate::server::handle::notify_loop)'s MPSC buffer
99-
/// to be available.
98+
/// Failed to send message to [`notify_loop()`](crate::server::handle::notify_loop)'s MPSC buffer.
10099
#[error("Timeout while sending notification to notify loop")]
101-
NotifyMpscSendTimeout,
100+
MpscTrySend,
102101
}

src/server/client_handle.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
},
1414
};
1515
use pwmp_client::pwmp_msg::{request::Request, response::Response};
16-
use std::{io::Read, net::SocketAddr, sync::Arc, time::Duration};
16+
use std::{io::Read, net::SocketAddr, sync::Arc};
1717
use tokio::{net::TcpStream, time::timeout};
1818
use tracing::{debug, error, warn};
1919

@@ -288,7 +288,6 @@ async fn notify_send<S: AsRef<str>>(
288288
.await?;
289289

290290
notify
291-
.send_timeout(push_message, Duration::from_secs(3))
292-
.await
293-
.map_err(|_| Error::NotifyMpscSendTimeout)
291+
.try_send(push_message)
292+
.map_err(|_| Error::MpscTrySend)
294293
}

0 commit comments

Comments
 (0)