Skip to main content

Module op_log_store

Module op_log_store 

Source
Expand description

Storage-backed OpLog implementation for the array CRDT sync subsystem.

§Storage layout

One entry per op, stored under Namespace::ArrayOpLog.

Composite key = [array_name_len: u8] [array_name_bytes] [hlc_bytes: 18]

The leading length byte allows:

  • Per-array prefix scans (build [len, name_bytes] as prefix).
  • Bounded range reads for scan_range: the HLC suffix is big-endian, so [make_key(array, from), successor(make_key(array, to))) holds exactly the array’s ops in the HLC range.

Name length constraint: u8 accommodates names up to 255 bytes. The array schema validator enforces this upper bound. If a name longer than 255 bytes arrives at KvOpLogStore::append, the method returns ArrayError::SegmentCorruption rather than silently truncating.

§Runtime requirement

The OpLog trait has synchronous methods. This implementation bridges into async storage via tokio::task::block_in_place, which requires the multi-thread Tokio runtime. The array sync subsystem is #[cfg(not(target_arch = "wasm32"))] only, and the embedder runtimes (FFI, CLI) are all multi-thread. Tests in this module use #[tokio::test(flavor = "multi_thread")] for the same reason.

Structs§

KvOpLogStore
Storage-backed append-only operation log for the array CRDT sync subsystem.