pub struct MemoryDatastore { /* private fields */ }Expand description
In-memory datastore used by examples and integration tests.
Stores the “command -> response” pairing for the simplest
commands without speaking the real protocol. Production
embedders use RedisDatastore or MemcacheDatastore.
Implementations§
Source§impl MemoryDatastore
impl MemoryDatastore
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a fresh empty store.
§Examples
use dynomite::embed::hooks::MemoryDatastore;
let ds = MemoryDatastore::new();
assert_eq!(ds.dispatch_count(), 0);Sourcepub fn dispatch_count(&self) -> u64
pub fn dispatch_count(&self) -> u64
Number of times Datastore::dispatch has been invoked.
§Examples
use dynomite::embed::hooks::MemoryDatastore;
let ds = MemoryDatastore::new();
assert_eq!(ds.dispatch_count(), 0);Source§impl MemoryDatastore
impl MemoryDatastore
Sourcepub fn insert(&self, bucket: &[u8], key: &[u8])
pub fn insert(&self, bucket: &[u8], key: &[u8])
Insert (bucket, key) into the in-memory listing index.
Idempotent: inserting the same (bucket, key) pair twice is
a no-op. Tests use this helper to seed the streaming list
path without speaking the real Riak protocol.
§Examples
use dynomite::embed::hooks::MemoryDatastore;
let ds = MemoryDatastore::new();
ds.insert(b"users", b"alice");
ds.insert(b"users", b"bob");
assert_eq!(ds.list_buckets_snapshot().len(), 1);
assert_eq!(ds.list_keys_snapshot(b"users").len(), 2);Sourcepub fn list_buckets_snapshot(&self) -> Vec<Bytes>
pub fn list_buckets_snapshot(&self) -> Vec<Bytes>
Snapshot of the bucket name set, sorted lexicographically.
§Examples
use dynomite::embed::hooks::MemoryDatastore;
let ds = MemoryDatastore::new();
assert!(ds.list_buckets_snapshot().is_empty());Sourcepub fn list_keys_snapshot(&self, bucket: &[u8]) -> Vec<Bytes>
pub fn list_keys_snapshot(&self, bucket: &[u8]) -> Vec<Bytes>
Snapshot of the keys in bucket, sorted lexicographically.
Returns an empty vector when the bucket is unknown.
§Examples
use dynomite::embed::hooks::MemoryDatastore;
let ds = MemoryDatastore::new();
assert!(ds.list_keys_snapshot(b"missing").is_empty());Trait Implementations§
Source§impl Clone for MemoryDatastore
impl Clone for MemoryDatastore
Source§fn clone(&self) -> MemoryDatastore
fn clone(&self) -> MemoryDatastore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Datastore for MemoryDatastore
impl Datastore for MemoryDatastore
Source§fn dispatch(&self, req: Msg) -> BoxFuture<'_, Result<Msg, DatastoreError>>
fn dispatch(&self, req: Msg) -> BoxFuture<'_, Result<Msg, DatastoreError>>
Forward a routed request and return the response message. Read more
Source§fn list_buckets_stream(&self) -> DatastoreByteStream
fn list_buckets_stream(&self) -> DatastoreByteStream
Stream the names of every bucket the datastore is aware of,
one
bytes::Bytes per bucket. Read moreSource§fn list_keys_stream(&self, bucket: &[u8]) -> DatastoreByteStream
fn list_keys_stream(&self, bucket: &[u8]) -> DatastoreByteStream
Source§fn supports(&self, _cmd: MsgType) -> bool
fn supports(&self, _cmd: MsgType) -> bool
Predicate used by the dispatcher to short-circuit
commands the backend cannot serve.
Source§fn riak_get<'a>(
&'a self,
_bucket: &'a [u8],
_key: &'a [u8],
) -> BoxFuture<'a, Result<Option<Vec<u8>>, DatastoreError>>
fn riak_get<'a>( &'a self, _bucket: &'a [u8], _key: &'a [u8], ) -> BoxFuture<'a, Result<Option<Vec<u8>>, DatastoreError>>
Read the object stored under
(bucket, key) against the
Riak K/V layer. Read moreSource§fn riak_put<'a>(
&'a self,
_bucket: &'a [u8],
_key: &'a [u8],
_value: &'a [u8],
_indexes: &'a [(Vec<u8>, Vec<u8>)],
) -> BoxFuture<'a, Result<(), DatastoreError>>
fn riak_put<'a>( &'a self, _bucket: &'a [u8], _key: &'a [u8], _value: &'a [u8], _indexes: &'a [(Vec<u8>, Vec<u8>)], ) -> BoxFuture<'a, Result<(), DatastoreError>>
Store
value under (bucket, key). indexes carries
(index_name, encoded_value) pairs to associate with the
object on the 2i layer. Read moreSource§fn riak_delete<'a>(
&'a self,
_bucket: &'a [u8],
_key: &'a [u8],
) -> BoxFuture<'a, Result<bool, DatastoreError>>
fn riak_delete<'a>( &'a self, _bucket: &'a [u8], _key: &'a [u8], ) -> BoxFuture<'a, Result<bool, DatastoreError>>
Delete the object stored under
(bucket, key). Returns
true when an object was removed, false when none
existed. Read moreSource§impl Debug for MemoryDatastore
impl Debug for MemoryDatastore
Source§impl Default for MemoryDatastore
impl Default for MemoryDatastore
Source§fn default() -> MemoryDatastore
fn default() -> MemoryDatastore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MemoryDatastore
impl !RefUnwindSafe for MemoryDatastore
impl Send for MemoryDatastore
impl Sync for MemoryDatastore
impl Unpin for MemoryDatastore
impl UnsafeUnpin for MemoryDatastore
impl !UnwindSafe for MemoryDatastore
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
Mutably borrows from an owned value. Read more