@@ -12,7 +12,7 @@ use thiserror::Error;
12
12
use tokio:: time:: sleep;
13
13
use tokio:: {
14
14
sync:: {
15
- mpsc:: { channel , Sender } ,
15
+ mpsc:: { unbounded_channel , UnboundedSender } ,
16
16
oneshot,
17
17
} ,
18
18
task:: JoinHandle ,
@@ -33,7 +33,7 @@ use eyre::{eyre, Context};
33
33
#[ derive( Debug ) ]
34
34
pub struct Socket {
35
35
/// queue for messages to be sent to the bridge server
36
- sender : Sender < ( Option < u64 > , Vec < u8 > ) > ,
36
+ sender : UnboundedSender < ( Option < u64 > , Vec < u8 > ) > ,
37
37
/// the handle of the task that writes on the websocket connection
38
38
_write_handle : JoinHandle < ( ) > ,
39
39
/// the handle of the task that reads on the websocket connection
@@ -96,11 +96,7 @@ impl Socket {
96
96
id : u64 ,
97
97
msg : SocketMessage ,
98
98
) -> eyre:: Result < ( ) > {
99
- if let Err ( _e) = self
100
- . sender
101
- . send ( ( Some ( id) , serde_json:: to_vec ( & msg) ?) )
102
- . await
103
- {
99
+ if let Err ( _e) = self . sender . send ( ( Some ( id) , serde_json:: to_vec ( & msg) ?) ) {
104
100
// not to let the requester to wait forever
105
101
const ERROR_MSG : & str = "\" Failed to send message to the queue\" " ;
106
102
if let Some ( ( _id, sender) ) = context. 0 . pending_requests . remove ( & id) {
@@ -215,7 +211,7 @@ impl Socket {
215
211
silent : true ,
216
212
} ;
217
213
let payload = serde_json:: to_vec ( & msg) ?;
218
- self . sender . send ( ( None , payload) ) . await ?;
214
+ self . sender . send ( ( None , payload) ) ?;
219
215
Ok ( ( ) )
220
216
}
221
217
@@ -225,8 +221,7 @@ impl Socket {
225
221
pub async fn connect ( url : Url , key : Key , handler : MessageHandler ) -> eyre:: Result < Self > {
226
222
let ( mut tx, rx) = connect ( url) . await ?. split ( ) ;
227
223
let context = handler. context . clone ( ) ;
228
- let ( sender, mut receiver) =
229
- channel :: < ( Option < u64 > , Vec < u8 > ) > ( context. 0 . pending_requests_limit ) ;
224
+ let ( sender, mut receiver) = unbounded_channel :: < ( Option < u64 > , Vec < u8 > ) > ( ) ;
230
225
let sender_out = sender. clone ( ) ;
231
226
232
227
// a task for reading from the websocket connection, decrypting the data
0 commit comments