1- use std:: { future:: Future , sync:: Arc } ;
1+ use std:: { future:: Future , sync:: Arc , time :: Duration } ;
22
33use fusio:: executor:: { Executor , Timer } ;
44use fusio_core:: MaybeSend ;
@@ -11,6 +11,9 @@ use crate::{
1111 DefaultExecutor ,
1212} ;
1313
14+ /// Default minimum interval between opportunistic orphan-recovery attempts.
15+ pub const DEFAULT_ORPHAN_RECOVERY_INTERVAL : Duration = Duration :: from_secs ( 3 ) ;
16+
1417/// ManifestContext shared across manifest components, parameterised by an executor that also
1518/// implements the timer abstraction.
1619#[ derive( Clone ) ]
3841 pub run_block_target_bytes : usize ,
3942 /// Max records per run data block.
4043 pub run_block_max_records : usize ,
44+ /// Minimum interval between opportunistic orphan-recovery attempts when opening write
45+ /// sessions.
46+ pub orphan_recovery_interval : Duration ,
4147}
4248
4349impl < E > ManifestContext < DefaultRetention , E >
5763 run_bloom_enabled : true ,
5864 run_block_target_bytes : 256 * 1024 ,
5965 run_block_max_records : 4096 ,
66+ orphan_recovery_interval : DEFAULT_ORPHAN_RECOVERY_INTERVAL ,
6067 }
6168 }
6269}
@@ -124,6 +131,7 @@ where
124131 run_bloom_enabled : self . run_bloom_enabled ,
125132 run_block_target_bytes : self . run_block_target_bytes ,
126133 run_block_max_records : self . run_block_max_records ,
134+ orphan_recovery_interval : self . orphan_recovery_interval ,
127135 }
128136 }
129137
@@ -219,6 +227,27 @@ where
219227 pub fn set_run_block_max_records ( & mut self , max_records : usize ) {
220228 self . run_block_max_records = max_records. max ( 1 ) ;
221229 }
230+
231+ /// Configure the minimum interval between opportunistic orphan-recovery attempts.
232+ /// `Duration::ZERO` is normalized to the crate default interval.
233+ pub fn with_orphan_recovery_interval ( mut self , interval : Duration ) -> Self {
234+ self . orphan_recovery_interval = normalize_orphan_recovery_interval ( interval) ;
235+ self
236+ }
237+
238+ /// Mutably configure the minimum interval between opportunistic orphan-recovery attempts.
239+ /// `Duration::ZERO` is normalized to the crate default interval.
240+ pub fn set_orphan_recovery_interval ( & mut self , interval : Duration ) {
241+ self . orphan_recovery_interval = normalize_orphan_recovery_interval ( interval) ;
242+ }
243+ }
244+
245+ fn normalize_orphan_recovery_interval ( interval : Duration ) -> Duration {
246+ if interval. is_zero ( ) {
247+ DEFAULT_ORPHAN_RECOVERY_INTERVAL
248+ } else {
249+ interval
250+ }
222251}
223252
224253impl < E > Default for ManifestContext < DefaultRetention , E >
0 commit comments