pub struct BlobStore { /* private fields */ }Expand description
Content-addressed blob store: index-backed or in-memory behind one
surface, so RegistryService and callers are unaffected by the variant.
Implementations§
Source§impl BlobStore
impl BlobStore
Sourcepub fn open(blobs_root: impl Into<PathBuf>) -> Result<Self, RegistryError>
pub fn open(blobs_root: impl Into<PathBuf>) -> Result<Self, RegistryError>
Open (creating if missing) the blob store rooted at blobs_root.
Recovery runs before the store is returned: a segment WITH a committed durable length is truncated to it (a torn tail from a mid-append crash never becomes readable), a segment shorter than its committed length is reported as corruption, and a segment WITHOUT an entry is left untouched (nothing references its bytes — and an absent entry is also the signature of a lost index DB, which must not be answered by destroying payloads).
A legacy blobs/{xx}/{hash}.bin layout without a blobs/index/
directory is rejected rather than served as an empty store.
Sourcepub fn memory() -> Self
pub fn memory() -> Self
Create an in-memory blob store.
Exists so the default in-memory registry supports geo writes: data lives until process shutdown, consistent with in-memory storage semantics.
Sourcepub fn put(
&self,
blob_id: StrHash,
payload: &[u8],
) -> Result<u64, RegistryError>
pub fn put( &self, blob_id: StrHash, payload: &[u8], ) -> Result<u64, RegistryError>
Store payload under blob_id (content-address validated here).
Returns the bytes written; a put of an id that already has a payload
is a no-op and returns 0 — the address is the commitment.
Sourcepub fn put_blobs(
&self,
blobs: &[(StrHash, Arc<[u8]>)],
) -> Result<(), RegistryError>
pub fn put_blobs( &self, blobs: &[(StrHash, Arc<[u8]>)], ) -> Result<(), RegistryError>
Batched, all-or-nothing blob write.
Every payload must be non-empty, is size-checked against
MAX_BLOB_BYTES, and is content-hash-validated before any
index write. Blobs already present are skipped; new blobs are
committed in one atomic index batch (a RocksDB WriteBatch in the
index-backed variant; the in-memory variant locks its map once), so a
failure leaves no partial entries. Content addressing makes a
whole-batch retry idempotent.
Sourcepub fn get(
&self,
ids: &[StrHash],
) -> Result<Vec<Option<Vec<u8>>>, RegistryError>
pub fn get( &self, ids: &[StrHash], ) -> Result<Vec<Option<Vec<u8>>>, RegistryError>
Fetch ids positionally; None marks a blob this store lacks.
Segment hits are grouped by segment and read in ascending offset order so a batch touching many records in one file reads with disk locality. Every segment record’s CRC32 is verified on read.
Sourcepub fn flush(&self) -> Result<(), RegistryError>
pub fn flush(&self) -> Result<(), RegistryError>
Flush the index MemTable to an SST file (no-op in memory).
Sourcepub fn compact_range(&self) -> Result<(), RegistryError>
pub fn compact_range(&self) -> Result<(), RegistryError>
Full-range compaction of the index column family (no-op in memory).
Sourcepub fn verify(&self) -> Result<BlobVerifyReport, RegistryError>
pub fn verify(&self) -> Result<BlobVerifyReport, RegistryError>
Offline integrity scan of the whole store (waratah blob verify).
Checks, per index entry, that the value decodes and that an inline
payload hashes to its own key (identity), and per segment locator,
that the record exists with a matching header length (the read path
treats a disagreement as fatal — so must the scan), CRC32, AND
payload identity — a locator pointing at another blob’s record has
a valid CRC and only the identity check catches it. Two locators
resolving to the same (segment, offset) are flagged separately.
Then walks every segment file sequentially, reporting records no
locator references as orphans and any undecodable tail as
corruption. A walk that hits an undecodable record aborts at that
offset (record framing is self-describing, so nothing past it can
be located without guessing); locators at or past the abort offset
are reported as unverified rather than dangling, because the
classic shape — preserved torn bytes below a committed durable
length, valid records appended after them — reads back fine. An
empty index over non-empty segments is flagged as the
lost-or-never-committed-index signature. verify itself
performs no writes; the store’s open (which the caller already
ran, and which may truncate torn tails past committed durable
lengths) is where recovery happens. Returns the report; the caller
decides severity from BlobVerifyReport::problems and
BlobVerifyReport::orphan_records.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BlobStore
impl RefUnwindSafe for BlobStore
impl Send for BlobStore
impl Sync for BlobStore
impl Unpin for BlobStore
impl UnsafeUnpin for BlobStore
impl UnwindSafe for BlobStore
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].