Skip to main content

SpoolWriter

Struct SpoolWriter 

Source
pub struct SpoolWriter { /* private fields */ }
Expand description

One spool batch is bounded by record count or wall-clock time; larger of the two is kept simple here.

Implementations§

Source§

impl SpoolWriter

Source

pub fn open( dir: impl Into<PathBuf>, max_bytes: u64, on_failure: AuditFailureMode, ) -> Result<Self>

Open a fresh batch in dir. Files are named <batch_id>.audit.bin / <batch_id>.audit.bin.crc.

§Errors

Returns io::Error when the directory cannot be created or the files cannot be opened for append.

Source

pub fn open_with_fsync( dir: impl Into<PathBuf>, max_bytes: u64, on_failure: AuditFailureMode, fsync_mode: AuditFsyncMode, ) -> Result<Self>

Same as Self::open but with an explicit fsync policy. Spec 11 § 6.4 / decision D6-5.

§Errors

Returns io::Error when the directory cannot be created or the files cannot be opened for append.

Source

pub fn append(&self, env: &ObsEnvelope) -> Result<()>

Append one envelope to the spool. Returns Err only when the underlying write or flush fails.

§Errors

I/O errors propagate from the underlying file writes.

Source

pub fn fsync_now(&self) -> Result<()>

Force an immediate fsync regardless of the configured policy. Used by Sink::flush / shutdown paths to guarantee that all AUDIT records on disk are durable before returning.

§Errors

Returns the underlying I/O error if sync_data fails.

Source

pub fn close(&self)

Close the current batch (the .audit.bin is left intact for the drainer / a later process to recover).

Source

pub fn on_failure(&self) -> AuditFailureMode

Configured failure mode (used by the AUDIT path to decide panic / abort / warn_only on append failure).

Source

pub fn dir(&self) -> PathBuf

Spool dir (used by tests and the drainer).

Source

pub fn bin_path(&self) -> PathBuf

Path of the active .audit.bin file (test helper).

Source

pub fn crc_path(&self) -> PathBuf

Path of the active .audit.bin.crc file (test helper).

Trait Implementations§

Source§

impl Debug for SpoolWriter

Source§

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

Formats the value using the given formatter. 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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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.