File tree Expand file tree Collapse file tree 4 files changed +24
-0
lines changed Expand file tree Collapse file tree 4 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 3
3
//! Types implementing an abstraction over IPC channels
4
4
use crate :: error:: Result ;
5
5
use std:: io:: { Read , Write } ;
6
+ use std:: time:: Duration ;
6
7
7
8
pub mod unix_socket;
8
9
@@ -18,4 +19,7 @@ impl<T: Read + Write> ReadWrite for T {}
18
19
pub trait Connect {
19
20
/// Connect to underlying IPC and return a readable and writeable stream
20
21
fn connect ( & self ) -> Result < Box < dyn ReadWrite > > ;
22
+
23
+ /// Set timeout for all produced streams.
24
+ fn set_timeout ( & mut self , timeout : Option < Duration > ) ;
21
25
}
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ impl Connect for Handler {
32
32
33
33
Ok ( Box :: from ( stream) )
34
34
}
35
+
36
+ fn set_timeout ( & mut self , timeout : Option < Duration > ) {
37
+ self . timeout = timeout;
38
+ }
35
39
}
36
40
37
41
impl Handler {
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use super::ipc_handler::{unix_socket, Connect};
5
5
use crate :: error:: { ClientErrorKind , Result } ;
6
6
use derivative:: Derivative ;
7
7
use parsec_interface:: requests:: { Request , Response } ;
8
+ use std:: time:: Duration ;
8
9
9
10
const DEFAULT_MAX_BODY_SIZE : usize = usize:: max_value ( ) ;
10
11
@@ -65,4 +66,14 @@ impl crate::BasicClient {
65
66
pub fn set_ipc_handler ( & mut self , ipc_handler : Box < dyn Connect > ) {
66
67
self . op_client . request_client . ipc_handler = ipc_handler;
67
68
}
69
+
70
+ /// Set the timeout for operations on the IPC stream.
71
+ ///
72
+ /// The value defaults to 1 second.
73
+ pub fn set_timeout ( & mut self , timeout : Option < Duration > ) {
74
+ self . op_client
75
+ . request_client
76
+ . ipc_handler
77
+ . set_timeout ( timeout) ;
78
+ }
68
79
}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use crate::error::Result;
8
8
use mockstream:: { FailingMockStream , SyncMockStream } ;
9
9
use parsec_interface:: requests:: ProviderID ;
10
10
use std:: ops:: { Deref , DerefMut } ;
11
+ use std:: time:: Duration ;
11
12
12
13
mod core_tests;
13
14
@@ -19,6 +20,8 @@ impl Connect for MockIpc {
19
20
fn connect ( & self ) -> Result < Box < dyn ReadWrite > > {
20
21
Ok ( Box :: from ( self . 0 . clone ( ) ) )
21
22
}
23
+
24
+ fn set_timeout ( & mut self , _timeout : Option < Duration > ) { }
22
25
}
23
26
24
27
struct FailingMockIpc ( FailingMockStream ) ;
@@ -27,6 +30,8 @@ impl Connect for FailingMockIpc {
27
30
fn connect ( & self ) -> Result < Box < dyn ReadWrite > > {
28
31
Ok ( Box :: from ( self . 0 . clone ( ) ) )
29
32
}
33
+
34
+ fn set_timeout ( & mut self , _timeout : Option < Duration > ) { }
30
35
}
31
36
32
37
struct TestBasicClient {
You can’t perform that action at this time.
0 commit comments