pub struct ObjectStoreBackend { /* private fields */ }Expand description
Object storage backend with optional local caching.
Delegates storage operations to a cloud object store (S3, GCS, Azure)
via the object_store crate. When a DiskCache is configured,
reads are served from the local cache when available.
§Segment Path Mapping
SegmentPath { namespace: "default", shard_id: 3, name: "seg_001.csx" } maps to
the object key ns_default/shard_3/seg_001.csx relative to the configured prefix.
Implementations§
Source§impl ObjectStoreBackend
impl ObjectStoreBackend
Sourcepub async fn new(config: ObjectStoreConfig) -> Result<Self>
pub async fn new(config: ObjectStoreConfig) -> Result<Self>
Create a new object store backend from configuration.
§Errors
Returns InvalidConfig if the URL scheme is not supported.
Sourcepub fn from_store(store: Arc<dyn ObjectStore>, cache: Option<DiskCache>) -> Self
pub fn from_store(store: Arc<dyn ObjectStore>, cache: Option<DiskCache>) -> Self
Create a backend from an existing ObjectStore instance.
Useful for testing with in-memory stores.
Create a backend from an existing ObjectStore instance.
Uses the default multipart threshold (8 MiB).
Sourcepub fn from_store_with_threshold(
store: Arc<dyn ObjectStore>,
cache: Option<DiskCache>,
multipart_threshold_bytes: usize,
) -> Self
pub fn from_store_with_threshold( store: Arc<dyn ObjectStore>, cache: Option<DiskCache>, multipart_threshold_bytes: usize, ) -> Self
Create a backend from an existing ObjectStore with a custom
multipart threshold.
Sourcepub async fn segment_size(&self, path: &SegmentPath) -> Result<Option<usize>>
pub async fn segment_size(&self, path: &SegmentPath) -> Result<Option<usize>>
Return the size of a remote segment via a HEAD request.
This avoids re-downloading the entire segment just to verify its
size after upload. Returns None if the object does not exist.
§Errors
Returns an error if the HEAD request fails (other than NotFound).
Sourcepub async fn object_size(&self, key: &str) -> Result<Option<usize>>
pub async fn object_size(&self, key: &str) -> Result<Option<usize>>
Return the size of an arbitrary object via a HEAD request.
None means the object is not there. Used to verify an upload landed
intact before the caller deletes the source.
§Errors
Returns an error if the HEAD request fails for any reason other than
NotFound.
Sourcepub async fn get(&self, key: &str) -> Result<Bytes>
pub async fn get(&self, key: &str) -> Result<Bytes>
Get an object from the store.
§Errors
Returns ObjStoreError::NotFound if the object does not exist,
or ObjStoreError::Store on other failures.
Trait Implementations§
Source§impl Debug for ObjectStoreBackend
impl Debug for ObjectStoreBackend
Source§impl StorageBackend for ObjectStoreBackend
impl StorageBackend for ObjectStoreBackend
Source§async fn put_segment(&self, path: &SegmentPath, data: &[u8]) -> Result<()>
async fn put_segment(&self, path: &SegmentPath, data: &[u8]) -> Result<()>
Source§async fn get_segment(&self, path: &SegmentPath) -> Result<Vec<u8>>
async fn get_segment(&self, path: &SegmentPath) -> Result<Vec<u8>>
Source§async fn get_range(
&self,
path: &SegmentPath,
offset: u64,
length: usize,
) -> Result<Vec<u8>>
async fn get_range( &self, path: &SegmentPath, offset: u64, length: usize, ) -> Result<Vec<u8>>
Source§async fn delete_segment(&self, path: &SegmentPath) -> Result<()>
async fn delete_segment(&self, path: &SegmentPath) -> Result<()>
Source§async fn list_segments(
&self,
namespace: &NamespaceId,
shard_id: &ShardId,
) -> Result<Vec<SegmentPath>>
async fn list_segments( &self, namespace: &NamespaceId, shard_id: &ShardId, ) -> Result<Vec<SegmentPath>>
Auto Trait Implementations§
impl !Freeze for ObjectStoreBackend
impl !RefUnwindSafe for ObjectStoreBackend
impl !UnwindSafe for ObjectStoreBackend
impl Send for ObjectStoreBackend
impl Sync for ObjectStoreBackend
impl Unpin for ObjectStoreBackend
impl UnsafeUnpin for ObjectStoreBackend
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more