@@ -28,7 +28,7 @@ pub struct MessageDispatcher<R> {
2828 pending_requests : Arc < Mutex < HashMap < RequestId , oneshot:: Sender < R > > > > ,
2929 writable_std : Mutex < Pin < Box < dyn tokio:: io:: AsyncWrite + Send + Sync > > > ,
3030 message_id_counter : Arc < AtomicI64 > ,
31- timeout_msec : u64 ,
31+ request_timeout : Duration ,
3232}
3333
3434impl < R > MessageDispatcher < R > {
@@ -38,21 +38,21 @@ impl<R> MessageDispatcher<R> {
3838 /// * `pending_requests` - A thread-safe map for storing pending request IDs and their response channels.
3939 /// * `writable_std` - A mutex-protected, pinned writer (e.g., stdout) for sending serialized messages.
4040 /// * `message_id_counter` - An atomic counter for generating unique request IDs.
41- /// * `timeout_msec ` - The timeout duration in milliseconds for awaiting responses.
41+ /// * `request_timeout ` - The timeout duration in milliseconds for awaiting responses.
4242 ///
4343 /// # Returns
4444 /// A new `MessageDispatcher` instance configured for MCP message handling.
4545 pub fn new (
4646 pending_requests : Arc < Mutex < HashMap < RequestId , oneshot:: Sender < R > > > > ,
4747 writable_std : Mutex < Pin < Box < dyn tokio:: io:: AsyncWrite + Send + Sync > > > ,
4848 message_id_counter : Arc < AtomicI64 > ,
49- timeout_msec : u64 ,
49+ request_timeout : Duration ,
5050 ) -> Self {
5151 Self {
5252 pending_requests,
5353 writable_std,
5454 message_id_counter,
55- timeout_msec ,
55+ request_timeout ,
5656 }
5757 }
5858
@@ -148,7 +148,7 @@ impl McpDispatch<ServerMessage, MessageFromClient> for MessageDispatcher<ServerM
148148
149149 if let Some ( rx) = rx_response {
150150 // Wait for the response with timeout
151- match await_timeout ( rx, Duration :: from_millis ( self . timeout_msec ) ) . await {
151+ match await_timeout ( rx, self . request_timeout ) . await {
152152 Ok ( response) => Ok ( Some ( response) ) ,
153153 Err ( error) => match error {
154154 TransportError :: OneshotRecvError ( _) => {
@@ -220,7 +220,7 @@ impl McpDispatch<ClientMessage, MessageFromServer> for MessageDispatcher<ClientM
220220 writable_std. flush ( ) . await ?;
221221
222222 if let Some ( rx) = rx_response {
223- match await_timeout ( rx, Duration :: from_millis ( self . timeout_msec ) ) . await {
223+ match await_timeout ( rx, self . request_timeout ) . await {
224224 Ok ( response) => Ok ( Some ( response) ) ,
225225 Err ( error) => Err ( error) ,
226226 }
0 commit comments