Struct JournalOptions
pub struct JournalOptions { /* private fields */ }Expand description
Everything a JournalStorage can be tuned with.
Every knob has a default that is right for the headline case — a handful of workers on a shared filesystem — and every one of them is stated here rather than hidden in the implementation.
use atune_core::storage::{Durability, JournalOptions};
use atune_core::id::WorkerId;
// A SLURM array task: identify yourself and choose the durability policy
// explicitly for the workload's crash-recovery requirements.
let options = JournalOptions::new()
.worker(WorkerId::new(7))
.durability(Durability::Os)
.snapshot_every(Some(4_096));Implementations§
§impl JournalOptions
impl JournalOptions
pub fn new() -> Self
pub fn new() -> Self
The defaults: worker 0, the system clock, a synced staged image per
record,
a snapshot every 1024 ops, a 120 s lock wait, a 60 s local lease
observation grace, a 30 s heartbeat interval and no re-enqueue on
fail-over.
pub const fn worker(self, worker: WorkerId) -> Self
pub const fn worker(self, worker: WorkerId) -> Self
Names this handle among the study’s workers.
Two workers sharing a journal must not share an id: the id is what
a stale-lock report, a fail-over decision and
FrozenTrial::worker all name. In
a SLURM array, SLURM_ARRAY_TASK_ID is exactly the right value.
pub fn clock(self, clock: Arc<dyn Clock>) -> Self
pub fn clock(self, clock: Arc<dyn Clock>) -> Self
Uses clock for record timestamps and diagnostic lock stamps. Lease
reclaim and trial failover do not compare this clock across processes.
Clocks need not agree for fencing correctness. Skew still appears in human-facing record chronology, so the system clock remains the operational default while tests may inject a deterministic clock.
pub const fn durability(self, durability: Durability) -> Self
pub const fn durability(self, durability: Durability) -> Self
Chooses whether publication also requests a containing-directory sync.
pub const fn snapshot_every(self, n: Option<u64>) -> Self
pub const fn snapshot_every(self, n: Option<u64>) -> Self
Snapshots every n ops; None never snapshots automatically.
pub const fn lock_timeout_millis(self, millis: u64) -> Self
pub const fn lock_timeout_millis(self, millis: u64) -> Self
How long a worker waits for the append lock before reporting failure.
If this is shorter than lock_grace_millis,
an abandoned new lease may time out rather than reach reclaim proof.
pub const fn lock_grace_millis(self, millis: u64) -> Self
pub const fn lock_grace_millis(self, millis: u64) -> Self
How long an unchanged new-lease owner identity/epoch must be observed locally before another worker may break it. Legacy symlink/file locks are never auto-reclaimed. A value of zero deliberately permits reclaim after one complete owner observation; use it only for an explicit immediate-reclaim policy.
It bounds how long a kill -9ed worker can block the study. Choose it
from the deployment’s reclaim policy; this API makes no universal
filesystem-latency or throughput claim.
pub const fn heartbeat_interval_millis(self, millis: u64) -> Self
pub const fn heartbeat_interval_millis(self, millis: u64) -> Self
The interval workers heartbeat at.
Fail-over’s grace period is twice this unless
stale_after_millis overrides it.
pub const fn stale_after_millis(self, millis: Option<u64>) -> Self
pub const fn stale_after_millis(self, millis: Option<u64>) -> Self
Overrides the fail-over grace period derived from the heartbeat interval.
pub const fn requeue_on_failover(self, requeue: bool) -> Self
pub const fn requeue_on_failover(self, requeue: bool) -> Self
Whether JournalStorage::fail_over_stale re-enqueues what it fails.
pub const fn max_record_bytes(self, bytes: usize) -> Self
pub const fn max_record_bytes(self, bytes: usize) -> Self
Caps one encoded JSONL header or operation line, including its newline.
The value must be positive and finite when the options are used to open
a journal; usize::MAX is not an unlimited sentinel.
pub const fn with_max_record_bytes(self, bytes: usize) -> Self
pub const fn with_max_record_bytes(self, bytes: usize) -> Self
Alias for Self::max_record_bytes.
pub const fn max_record_entries(self, entries: usize) -> Self
pub const fn max_record_entries(self, entries: usize) -> Self
Caps decoded JSON array/map entries in one JSONL header or operation line, including fixed envelope fields.
pub const fn with_max_record_entries(self, entries: usize) -> Self
pub const fn with_max_record_entries(self, entries: usize) -> Self
Alias for Self::max_record_entries.
pub const fn max_journal_bytes(self, bytes: usize) -> Self
pub const fn max_journal_bytes(self, bytes: usize) -> Self
Caps the complete canonical JSONL image after one publication.
pub const fn with_max_journal_bytes(self, bytes: usize) -> Self
pub const fn with_max_journal_bytes(self, bytes: usize) -> Self
Alias for Self::max_journal_bytes.
pub const fn max_snapshot_bytes(self, bytes: usize) -> Self
pub const fn max_snapshot_bytes(self, bytes: usize) -> Self
Caps the encoded snapshot side file.
pub const fn with_max_snapshot_bytes(self, bytes: usize) -> Self
pub const fn with_max_snapshot_bytes(self, bytes: usize) -> Self
Alias for Self::max_snapshot_bytes.
pub const fn max_records(self, records: usize) -> Self
pub const fn max_records(self, records: usize) -> Self
Caps decoded Journal operation records and snapshot collection entries.
pub const fn with_max_records(self, records: usize) -> Self
pub const fn with_max_records(self, records: usize) -> Self
Alias for Self::max_records.
pub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validates all finite input and image limits before touching the path.
§Errors
Returns Error::ResourceLimit
when a limit is zero or cannot be incremented for bounded admission.
Trait Implementations§
§impl Clone for JournalOptions
impl Clone for JournalOptions
§fn clone(&self) -> JournalOptions
fn clone(&self) -> JournalOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more