Trait mz_persist::location::Blob
source · pub trait Blob:
Debug
+ Send
+ Sync {
// Required methods
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<SegmentedBytes>, ExternalError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_keys_and_metadata<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key_prefix: &'life1 str,
f: &'life2 mut (dyn FnMut(BlobMetadata<'_>) + Send + Sync),
) -> Pin<Box<dyn Future<Output = Result<(), ExternalError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), ExternalError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<usize>, ExternalError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn restore<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), ExternalError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
An abstraction over read-write access to a bytes key
->bytes value
store.
Implementations are required to be linearizable.
TODO: Consider whether this can be relaxed. Since our usage is write-once
modify-never, it certainly seems like we could by adding retries around
get
to wait for a non-linearizable set
to show up. However, the tricky
bit comes once we stop handing out seqno capabilities to readers and have to
start reasoning about “this set hasn’t show up yet” vs “the blob has already
been deleted”. Another tricky problem is the same but for a deletion when
the first attempt timed out.
Required Methods§
sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<SegmentedBytes>, ExternalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<SegmentedBytes>, ExternalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns a reference to the value corresponding to the key.
sourcefn list_keys_and_metadata<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key_prefix: &'life1 str,
f: &'life2 mut (dyn FnMut(BlobMetadata<'_>) + Send + Sync),
) -> Pin<Box<dyn Future<Output = Result<(), ExternalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn list_keys_and_metadata<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key_prefix: &'life1 str,
f: &'life2 mut (dyn FnMut(BlobMetadata<'_>) + Send + Sync),
) -> Pin<Box<dyn Future<Output = Result<(), ExternalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
List all of the keys in the map with metadata about the entry.
Can be optionally restricted to only list keys starting with a given prefix.
sourcefn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), ExternalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), ExternalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Inserts a key-value pair into the map.
Writes must be atomic and either succeed or leave the previous value intact.
sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<usize>, ExternalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<usize>, ExternalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove a key from the map.
Returns Some and the size of the deleted blob if if exists. Succeeds and returns None if it does not exist.
sourcefn restore<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), ExternalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn restore<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), ExternalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Restores a previously-deleted key to the map, if possible.
Returns successfully if the key exists after this call: perhaps because it already existed or was restored. (In particular, this makes restore idempotent.) Fails if we were unable to restore any value for that key: perhaps the key was never written, or was permanently deleted.
It is acceptable for Blob::restore to be unable to restore keys, in which case this method should succeed iff the key exists.