Skip to main content

BlobStore

Struct BlobStore 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn flush(&self) -> Result<(), RegistryError>

Flush the index MemTable to an SST file (no-op in memory).

Source

pub fn compact_range(&self) -> Result<(), RegistryError>

Full-range compaction of the index column family (no-op in memory).

Source

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§

Source§

impl Debug for BlobStore

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,