Skip to main content

JournalOptions

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

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

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

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

Chooses whether publication also requests a containing-directory sync.

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

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

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

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

Overrides the fail-over grace period derived from the heartbeat interval.

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

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 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 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 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 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

Alias for Self::max_records.

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

§

fn clone(&self) -> JournalOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for JournalOptions

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Default for JournalOptions

§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more