@@ -139,6 +139,7 @@ pub struct Replicator<C, I> {
139139 injector : I ,
140140 state : ReplicatorState ,
141141 frames_synced : usize ,
142+ max_handshake_retries : usize ,
142143}
143144
144145const INJECTOR_BUFFER_CAPACITY : usize = 10 ;
@@ -185,14 +186,20 @@ where
185186 injector,
186187 state : ReplicatorState :: NeedHandshake ,
187188 frames_synced : 0 ,
189+ max_handshake_retries : HANDSHAKE_MAX_RETRIES ,
188190 }
189191 }
190192
191- /// for a handshake on next call to replicate.
193+ /// force a handshake on next call to replicate.
192194 pub fn force_handshake ( & mut self ) {
193195 self . state = ReplicatorState :: NeedHandshake ;
194196 }
195197
198+ /// configure number of handshake retries.
199+ pub fn set_primary_handshake_retries ( & mut self , retries : usize ) {
200+ self . max_handshake_retries = retries;
201+ }
202+
196203 pub fn client_mut ( & mut self ) -> & mut C {
197204 & mut self . client
198205 }
@@ -208,7 +215,7 @@ where
208215
209216 pub async fn try_perform_handshake ( & mut self ) -> Result < ( ) , Error > {
210217 let mut error_printed = false ;
211- for _ in 0 ..HANDSHAKE_MAX_RETRIES {
218+ for _ in 0 ..self . max_handshake_retries {
212219 tracing:: debug!( "Attempting to perform handshake with primary." ) ;
213220 match self . client . handshake ( ) . await {
214221 Ok ( _) => {
0 commit comments