@@ -190,6 +190,10 @@ pub trait ProcSettings {
190
190
/// Getter of the processor's adaptor configuration path
191
191
fn get_adaptor_config_path ( & self ) -> Option < & String > ;
192
192
193
+ /// Getter of the restart delay that must be apply to the processor if an error is trigger.
194
+ /// Return the duration to be add to every restart, and the max duration wait between restarts in seconds.
195
+ fn get_proc_restart_delay ( & self ) -> ( Duration , u32 ) ;
196
+
193
197
/// Getter of the processor's adaptor configuration
194
198
fn get_adaptor_config < C > ( & self ) -> Result < C , :: config:: ConfigError >
195
199
where
@@ -219,7 +223,7 @@ pub trait ProcBusParam {
219
223
fn get_proc_id ( & self ) -> u32 ;
220
224
221
225
/// Provide the ProSA name based on ProSA settings
222
- fn name ( & self ) -> & String ;
226
+ fn name ( & self ) -> & str ;
223
227
}
224
228
225
229
impl Debug for dyn ProcBusParam {
@@ -230,6 +234,9 @@ impl Debug for dyn ProcBusParam {
230
234
231
235
/// Trait to define all processor handle functions
232
236
pub trait ProcEpilogue {
237
+ /// Getter to know timer for processor restart in case of error
238
+ fn get_proc_restart_delay ( & self ) -> ( std:: time:: Duration , u32 ) ;
239
+
233
240
/// Method to remove the processor with a signal queue to the main task
234
241
///
235
242
/// Once the processor is removed, all its associated service will be remove
@@ -258,7 +265,7 @@ where
258
265
self . id
259
266
}
260
267
261
- fn name ( & self ) -> & String {
268
+ fn name ( & self ) -> & str {
262
269
self . main . name ( )
263
270
}
264
271
}
@@ -457,7 +464,8 @@ where
457
464
. thread_name ( proc_name. clone ( ) )
458
465
. build ( )
459
466
. unwrap ( ) ;
460
- let mut wait_time = Duration :: ZERO ;
467
+ let proc_restart_delay = self . get_proc_restart_delay ( ) ;
468
+ let mut wait_time = proc_restart_delay. 0 ;
461
469
loop {
462
470
if let Err ( proc_err) = rt. block_on ( self . internal_run ( proc_name. clone ( ) ) ) {
463
471
let recovery_duration = proc_err. recovery_duration ( ) ;
@@ -494,9 +502,9 @@ where
494
502
return ;
495
503
}
496
504
497
- // Don't wait more than 5 minutes btween restarts
498
- if wait_time. as_secs ( ) < 300 {
499
- wait_time += Duration :: from_millis ( 50 ) ;
505
+ // Don't wait more than the restart delay parameter
506
+ if wait_time. as_secs ( ) < proc_restart_delay . 1 as u64 {
507
+ wait_time += proc_restart_delay . 0 ;
500
508
wait_time *= 2 ;
501
509
}
502
510
}
0 commit comments