pub struct GrpcKvClient { /* private fields */ }Expand description
gRPC-based key-value store client
Implements remote CRUD operations via gRPC protocol. All write operations use strong consistency.
Implementations§
Source§impl GrpcKvClient
impl GrpcKvClient
Sourcepub async fn put(
&self,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
) -> Result<(), ClientApiError>
pub async fn put( &self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, ) -> Result<(), ClientApiError>
Stores a value with strong consistency
§Errors
crate::ClientApiError::Networkon network failurescrate::ClientApiError::Protocolfor protocol errorscrate::ClientApiError::Storagefor server-side storage errors
Sourcepub async fn put_with_ttl(
&self,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
ttl_secs: u64,
) -> Result<(), ClientApiError>
pub async fn put_with_ttl( &self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, ttl_secs: u64, ) -> Result<(), ClientApiError>
Stores a value with TTL (time-to-live) and strong consistency
Key will automatically expire and be deleted after ttl_secs seconds.
§Arguments
key- The key to storevalue- The value to storettl_secs- Time-to-live in seconds
§Errors
crate::ClientApiError::Networkon network failurescrate::ClientApiError::Protocolfor protocol errorscrate::ClientApiError::Storagefor server-side storage errors
Sourcepub async fn delete(&self, key: impl AsRef<[u8]>) -> Result<(), ClientApiError>
pub async fn delete(&self, key: impl AsRef<[u8]>) -> Result<(), ClientApiError>
Deletes a key with strong consistency guarantees
Permanently removes the specified key and its associated value from the store.
§Parameters
key: The byte-serialized key to delete. Supports any type implementingAsRef<[u8]>(e.g.String,&str,Vec<u8>)
§Errors
crate::ClientApiError::Networkif unable to reach the leader nodecrate::ClientApiError::Protocolfor protocol errorscrate::ClientApiError::Storagefor server-side storage errors
pub async fn get_linearizable( &self, key: impl AsRef<[u8]>, ) -> Result<Option<ClientResult>, ClientApiError>
pub async fn get_lease( &self, key: impl AsRef<[u8]>, ) -> Result<Option<ClientResult>, ClientApiError>
pub async fn get_eventual( &self, key: impl AsRef<[u8]>, ) -> Result<Option<ClientResult>, ClientApiError>
Sourcepub async fn get(
&self,
key: impl AsRef<[u8]>,
) -> Result<Option<ClientResult>, ClientApiError>
pub async fn get( &self, key: impl AsRef<[u8]>, ) -> Result<Option<ClientResult>, ClientApiError>
Retrieves a single key’s value using server’s default consistency policy
Uses the cluster’s configured default consistency policy as defined in the server’s ReadConsistencyConfig.default_policy setting.
§Parameters
key- The key to retrieve, accepts any type implementingAsRef<[u8]>
§Returns
Ok(Some(ClientResult))- Key exists, returns key-value pairOk(None)- Key does not exist in the storeErr(ClientApiError)- Read failed due to network or consistency issues
Sourcepub async fn get_with_policy(
&self,
key: impl AsRef<[u8]>,
consistency_policy: Option<ReadConsistencyPolicy>,
) -> Result<Option<ClientResult>, ClientApiError>
pub async fn get_with_policy( &self, key: impl AsRef<[u8]>, consistency_policy: Option<ReadConsistencyPolicy>, ) -> Result<Option<ClientResult>, ClientApiError>
Retrieves a single key’s value with explicit consistency policy
Allows client to override server’s default consistency policy for this specific request. If server’s allow_client_override is false, the override will be ignored.
§Parameters
key- The key to retrieve, accepts any type implementingAsRef<[u8]>policy- Explicit consistency policy for this request
Sourcepub async fn get_multi(
&self,
keys: impl IntoIterator<Item = impl AsRef<[u8]>>,
) -> Result<Vec<Option<ClientResult>>, ClientApiError>
pub async fn get_multi( &self, keys: impl IntoIterator<Item = impl AsRef<[u8]>>, ) -> Result<Vec<Option<ClientResult>>, ClientApiError>
Fetches multiple keys using server’s default consistency policy
Uses the cluster’s configured default consistency policy as defined in the server’s ReadConsistencyConfig.default_policy setting.
Sourcepub async fn get_multi_with_policy(
&self,
keys: impl IntoIterator<Item = impl AsRef<[u8]>>,
consistency_policy: Option<ReadConsistencyPolicy>,
) -> Result<Vec<Option<ClientResult>>, ClientApiError>
pub async fn get_multi_with_policy( &self, keys: impl IntoIterator<Item = impl AsRef<[u8]>>, consistency_policy: Option<ReadConsistencyPolicy>, ) -> Result<Vec<Option<ClientResult>>, ClientApiError>
Fetches multiple keys with explicit consistency policy override
Allows client to override server’s default consistency policy for this batch request. If server’s allow_client_override is false, the override will be ignored.
Sourcepub async fn watch(
&self,
key: impl AsRef<[u8]>,
) -> Result<Streaming<WatchResponse>, ClientApiError>
pub async fn watch( &self, key: impl AsRef<[u8]>, ) -> Result<Streaming<WatchResponse>, ClientApiError>
Watch for changes on a specific key
Returns a stream of watch events whenever the specified key is modified (PUT or DELETE). The stream will continue until the client drops the receiver or disconnects.
§Arguments
key- The exact key to watch (prefix/range watch not supported in v1)
§Returns
Ok(Streaming<WatchResponse>)- Stream of watch eventsErr(ClientApiError)- If watch feature is disabled or connection fails
§Example
use futures::StreamExt;
let mut stream = client.kv().watch("my_key").await?;
while let Some(event) = stream.next().await {
match event {
Ok(response) => println!("Key changed: {:?}", response),
Err(e) => eprintln!("Watch error: {:?}", e),
}
}Trait Implementations§
Source§impl Clone for GrpcKvClient
impl Clone for GrpcKvClient
Source§fn clone(&self) -> GrpcKvClient
fn clone(&self) -> GrpcKvClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl KvClient for GrpcKvClient
impl KvClient for GrpcKvClient
Source§fn put<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
value: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), KvClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcKvClient: 'async_trait,
fn put<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
value: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), KvClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcKvClient: 'async_trait,
Source§fn put_with_ttl<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
value: impl AsRef<[u8]> + Send + 'async_trait,
ttl_secs: u64,
) -> Pin<Box<dyn Future<Output = Result<(), KvClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcKvClient: 'async_trait,
fn put_with_ttl<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
value: impl AsRef<[u8]> + Send + 'async_trait,
ttl_secs: u64,
) -> Pin<Box<dyn Future<Output = Result<(), KvClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcKvClient: 'async_trait,
Source§fn get<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, KvClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcKvClient: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, KvClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcKvClient: 'async_trait,
Source§fn get_multi<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [Bytes],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Bytes>>, KvClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
GrpcKvClient: 'async_trait,
fn get_multi<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [Bytes],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Bytes>>, KvClientError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
GrpcKvClient: 'async_trait,
Auto Trait Implementations§
impl Freeze for GrpcKvClient
impl !RefUnwindSafe for GrpcKvClient
impl Send for GrpcKvClient
impl Sync for GrpcKvClient
impl Unpin for GrpcKvClient
impl !UnwindSafe for GrpcKvClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request