Skip to content

Commit 60d45ee

Browse files
committed
fix: background orphan recovery and wasm aws context send bounds
1 parent 449f948 commit 60d45ee

File tree

5 files changed

+358
-24
lines changed

5 files changed

+358
-24
lines changed

fusio-manifest/src/context.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{future::Future, sync::Arc};
1+
use std::{future::Future, sync::Arc, time::Duration};
22

33
use fusio::executor::{Executor, Timer};
44
use 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)]
@@ -38,6 +41,9 @@ where
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

4349
impl<E> ManifestContext<DefaultRetention, E>
@@ -57,6 +63,7 @@ where
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

224253
impl<E> Default for ManifestContext<DefaultRetention, E>

0 commit comments

Comments
 (0)