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
impl SpoolWriter
Sourcepub fn open(
dir: impl Into<PathBuf>,
max_bytes: u64,
on_failure: AuditFailureMode,
) -> Result<Self>
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.
Sourcepub fn open_with_fsync(
dir: impl Into<PathBuf>,
max_bytes: u64,
on_failure: AuditFailureMode,
fsync_mode: AuditFsyncMode,
) -> Result<Self>
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.
Sourcepub fn append(&self, env: &ObsEnvelope) -> Result<()>
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.
Sourcepub fn fsync_now(&self) -> Result<()>
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.
Sourcepub fn close(&self)
pub fn close(&self)
Close the current batch (the .audit.bin is left intact for
the drainer / a later process to recover).
Sourcepub fn on_failure(&self) -> AuditFailureMode
pub fn on_failure(&self) -> AuditFailureMode
Configured failure mode (used by the AUDIT path to decide
panic / abort / warn_only on append failure).