Skip to main content

JournalSource

Trait JournalSource 

Source
pub trait JournalSource: Send {
    // Required methods
    fn open(&mut self) -> Result<(), UsnError>;
    fn query(&mut self) -> Result<JournalView, UsnError>;
    fn read_blocking(
        &mut self,
        buf: &mut Vec<u8>,
    ) -> Result<ReadOutcome, UsnError>;
    fn journal_id(&self) -> u64;
    fn next_usn(&self) -> i64;
    fn set_next_usn(&mut self, usn: i64);
    fn open_stat_fetcher(&self) -> Result<Box<dyn StatFetcher>, UsnError>;
}
Expand description

One volume’s USN journal session, reopenable across journal-gone rescans. open must succeed before any other method is called (the worker guarantees this; implementations may panic otherwise — the worker’s panic firewall turns that into a visible VolumeFailed).

Required Methods§

Source

fn open(&mut self) -> Result<(), UsnError>

(Re)open the journal, creating it when missing. Positions the cursor at the journal’s current end. Called once per establish cycle: at start and after every journal-gone rescan.

Source

fn query(&mut self) -> Result<JournalView, UsnError>

Live journal identity/retention for checkpoint validation.

Source

fn read_blocking(&mut self, buf: &mut Vec<u8>) -> Result<ReadOutcome, UsnError>

Blocking read of the next batch. Semantics the worker relies on: blocks until records exist, then returns them and advances the cursor past the batch; Gone when the journal died under us; Err on an unrecoverable failure. An empty Records batch is a benign wakeup — the worker re-checks its stop flag and reads again (fakes use this to unblock on stop; the live read returns on the next volume write, which is what keeps Engine::shutdown’s join prompt).

Source

fn journal_id(&self) -> u64

Journal id of the open session (checkpoint identity).

Source

fn next_usn(&self) -> i64

Cursor the next read starts at (the value persisted in checkpoints).

Source

fn set_next_usn(&mut self, usn: i64)

Reposition the cursor (a snapshot restore replays from its persisted checkpoint instead of the journal’s current end).

Source

fn open_stat_fetcher(&self) -> Result<Box<dyn StatFetcher>, UsnError>

Size/mtime fetcher bound to the same volume, opened once per tail session. Per-record stat calls were already dynamic (usn::apply).

Implementors§