pub struct JsonlWriter { /* private fields */ }Expand description
Append-only writer for the events JSONL log. Holds an advisory
cross-platform file lock around each append + fsync, so that
concurrent producers (auto-capture hook + manual task-journal event + MCP server) cannot interleave bytes — O_APPEND alone
is not atomic on Windows.
The trade-off: every append takes one syscall to acquire the lock and one more to release it. For a journal — which sees a handful of events per minute — this overhead is negligible and far cheaper than recovery from a corrupt JSONL line.
Implementations§
Source§impl JsonlWriter
impl JsonlWriter
pub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn append(&mut self, event: &Event) -> Result<()>
Sourcepub fn flush_durable(&mut self) -> Result<()>
pub fn flush_durable(&mut self) -> Result<()>
Force the file’s bytes through to durable storage. Holds the exclusive lock so no concurrent writer can sneak an append between us and the fsync.
pub fn path(&self) -> &Path
Auto Trait Implementations§
impl Freeze for JsonlWriter
impl RefUnwindSafe for JsonlWriter
impl Send for JsonlWriter
impl Sync for JsonlWriter
impl Unpin for JsonlWriter
impl UnsafeUnpin for JsonlWriter
impl UnwindSafe for JsonlWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more