@@ -16,6 +16,8 @@ use crate::proto::{OpCode, PredefinedXid, RemoveWatchesRequest};
16
16
pub struct Depot {
17
17
xid : Xid ,
18
18
19
+ // If ongoing authes are interruptted due to disconnection, they will be retried after
20
+ // session reestablishment as auth failure will terminate session.
19
21
pending_authes : Vec < SessionOperation > ,
20
22
21
23
writing_slices : Vec < IoSlice < ' static > > ,
@@ -30,7 +32,7 @@ pub struct Depot {
30
32
}
31
33
32
34
impl Depot {
33
- pub fn for_serving ( ) -> Depot {
35
+ pub fn new ( ) -> Self {
34
36
let writing_capacity = 128usize ;
35
37
Depot {
36
38
xid : Default :: default ( ) ,
@@ -39,34 +41,18 @@ impl Depot {
39
41
writing_slices : Vec :: with_capacity ( writing_capacity) ,
40
42
writing_operations : VecDeque :: with_capacity ( writing_capacity) ,
41
43
written_operations : HashMap :: with_capacity ( 128 ) ,
42
- pending_operations : Default :: default ( ) ,
44
+ pending_operations : VecDeque :: with_capacity ( 32 ) ,
43
45
watching_paths : HashMap :: with_capacity ( 32 ) ,
44
46
unwatching_paths : HashMap :: with_capacity ( 32 ) ,
45
47
}
46
48
}
47
49
48
- pub fn for_connecting ( ) -> Depot {
49
- Depot {
50
- xid : Default :: default ( ) ,
51
- sasl : false ,
52
- pending_authes : Default :: default ( ) ,
53
- writing_slices : Vec :: with_capacity ( 10 ) ,
54
- writing_operations : VecDeque :: with_capacity ( 10 ) ,
55
- written_operations : HashMap :: with_capacity ( 10 ) ,
56
- pending_operations : VecDeque :: with_capacity ( 10 ) ,
57
- watching_paths : HashMap :: new ( ) ,
58
- unwatching_paths : HashMap :: new ( ) ,
59
- }
60
- }
61
-
62
- /// Clear all buffered operations from previous run.
63
- pub fn clear ( & mut self ) {
64
- self . xid = Default :: default ( ) ;
50
+ /// Reset state and clear buffered operations from previous run except `pending_authes`.
51
+ pub fn reset ( & mut self ) {
52
+ // We don't reset xid, so we get continuous xid (ignoring the overflow) even in case of
53
+ // reconnection. This is helpful in diagnosis.
65
54
self . sasl = false ;
66
- self . pending_authes . clear ( ) ;
67
55
self . writing_slices . clear ( ) ;
68
- self . watching_paths . clear ( ) ;
69
- self . unwatching_paths . clear ( ) ;
70
56
self . writing_operations . clear ( ) ;
71
57
self . written_operations . clear ( ) ;
72
58
self . pending_operations . clear ( ) ;
0 commit comments