pub struct GrpcClient { /* 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 GrpcClient
impl GrpcClient
Sourcepub async fn get_with_policy(
&self,
key: impl AsRef<[u8]>,
consistency_policy: Option<ReadConsistencyPolicy>,
) -> Result<Option<KvEntry>, ClientApiError>
pub async fn get_with_policy( &self, key: impl AsRef<[u8]>, consistency_policy: Option<ReadConsistencyPolicy>, ) -> Result<Option<KvEntry>, 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_with_policy(
&self,
keys: impl IntoIterator<Item = impl AsRef<[u8]>>,
consistency_policy: Option<ReadConsistencyPolicy>,
) -> Result<Vec<Option<KvEntry>>, ClientApiError>
pub async fn get_multi_with_policy( &self, keys: impl IntoIterator<Item = impl AsRef<[u8]>>, consistency_policy: Option<ReadConsistencyPolicy>, ) -> Result<Vec<Option<KvEntry>>, 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_membership(
&self,
) -> Result<Streaming<MembershipSnapshot>, ClientApiError>
pub async fn watch_membership( &self, ) -> Result<Streaming<MembershipSnapshot>, ClientApiError>
Subscribe to committed cluster membership changes.
Immediately yields the current MembershipSnapshot on connect, then one
snapshot per committed ConfChange (AddNode, Promote, Remove).
The stream ends with Err(UNAVAILABLE) when the server shuts down;
callers should reconnect and re-subscribe.
Use committed_index as an idempotency key to deduplicate retries.
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 to a specific key
Returns a stream of watch events when the key’s value changes. The stream will continue until explicitly closed or a connection error occurs.
§Arguments
key- The key to watch
§Returns
A streaming response that yields WatchResponse events
§Errors
Returns error if unable to establish watch connection
Sourcepub async fn watch_prefix(
&self,
prefix: impl AsRef<[u8]>,
) -> Result<Streaming<WatchResponse>, ClientApiError>
pub async fn watch_prefix( &self, prefix: impl AsRef<[u8]>, ) -> Result<Streaming<WatchResponse>, ClientApiError>
Watch all keys under a path prefix.
prefix must start with ‘/’ and end with ‘/’, e.g. b"/services/".
Returns a stream of events for any key whose path begins with the prefix.
Trait Implementations§
Source§impl ClientApi for GrpcClient
impl ClientApi for GrpcClient
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<(), ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: '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<(), ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: '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<(), ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: '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<(), ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: '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>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
Source§fn get_multi<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [Bytes],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Bytes>>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
GrpcClient: 'async_trait,
fn get_multi<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [Bytes],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Bytes>>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
GrpcClient: 'async_trait,
Source§fn delete<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
Source§fn compare_and_swap<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
expected_value: Option<impl AsRef<[u8]> + Send + 'async_trait>,
new_value: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<bool, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
fn compare_and_swap<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
expected_value: Option<impl AsRef<[u8]> + Send + 'async_trait>,
new_value: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<bool, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
Source§fn list_members<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<NodeMeta>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
fn list_members<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<NodeMeta>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
Source§fn get_leader_id<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<u32>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
fn get_leader_id<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<u32>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
Source§fn get_multi_with_policy<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [Bytes],
consistency_policy: Option<ReadConsistencyPolicy>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Bytes>>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
GrpcClient: 'async_trait,
fn get_multi_with_policy<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [Bytes],
consistency_policy: Option<ReadConsistencyPolicy>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Bytes>>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
GrpcClient: 'async_trait,
Source§fn get_linearizable<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
fn get_linearizable<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
Source§fn get_lease<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
fn get_lease<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
Source§fn get_eventual<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
fn get_eventual<'life0, 'async_trait>(
&'life0 self,
key: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
Source§fn scan_prefix<'life0, 'async_trait>(
&'life0 self,
prefix: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<ScanResult, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
fn scan_prefix<'life0, 'async_trait>(
&'life0 self,
prefix: impl AsRef<[u8]> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<ScanResult, ClientApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
GrpcClient: 'async_trait,
(key, value) pairs whose key starts with prefix, plus
a revision that anchors watch event deduplication. Read moreSource§impl Clone for GrpcClient
impl Clone for GrpcClient
Source§fn clone(&self) -> GrpcClient
fn clone(&self) -> GrpcClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for GrpcClient
impl !RefUnwindSafe for GrpcClient
impl Send for GrpcClient
impl Sync for GrpcClient
impl Unpin for GrpcClient
impl UnsafeUnpin for GrpcClient
impl !UnwindSafe for GrpcClient
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