pub struct KvClient { /* private fields */ }Expand description
Client for KV operations.
Implementations§
Source§impl KvClient
impl KvClient
Sourcepub fn max_decoding_message_size(self, limit: usize) -> Self
pub fn max_decoding_message_size(self, limit: usize) -> Self
Limits the maximum size of a decoded message.
Default: 4MB
Sourcepub fn max_encoding_message_size(self, limit: usize) -> Self
pub fn max_encoding_message_size(self, limit: usize) -> Self
Limits the maximum size of an encoded message.
Default: usize::MAX
Sourcepub async fn put(
&mut self,
key: impl Into<Vec<u8>>,
value: impl Into<Vec<u8>>,
options: Option<PutOptions>,
) -> Result<PutResponse, Error>
pub async fn put( &mut self, key: impl Into<Vec<u8>>, value: impl Into<Vec<u8>>, options: Option<PutOptions>, ) -> Result<PutResponse, Error>
Puts the given key into the key-value store. A put request increments the revision of the key-value store and generates one event in the event history.
Sourcepub async fn get(
&mut self,
key: impl Into<Vec<u8>>,
options: Option<GetOptions>,
) -> Result<GetResponse, Error>
pub async fn get( &mut self, key: impl Into<Vec<u8>>, options: Option<GetOptions>, ) -> Result<GetResponse, Error>
Gets the key or a range of keys from the store.
Sourcepub async fn get_stream(
&mut self,
key: impl Into<Vec<u8>>,
options: Option<GetOptions>,
) -> Result<GetStreamResponse, Error>
pub async fn get_stream( &mut self, key: impl Into<Vec<u8>>, options: Option<GetOptions>, ) -> Result<GetStreamResponse, Error>
The streaming version of get, which was introduced in etcd v3.7.
It returns the same result as get, but the server splits the response into a sequence of
chunks and streams them to the client. This avoids buffering large ranges entirely in
memory on either side.
Field population across chunks:
- Kvs - each chunk carries a disjoint slice of the result. Concatenating the
kvsfrom every chunk in the order they arrive yields the same key set as a single Range call (KvClient::get). - Header, More, Count - populated only on the final chunk, and only when the stream completes without error. Earlier chunks leave these fields zero-valued.
Read RangeStream for more details.
Sourcepub async fn delete(
&mut self,
key: impl Into<Vec<u8>>,
options: Option<DeleteOptions>,
) -> Result<DeleteResponse, Error>
pub async fn delete( &mut self, key: impl Into<Vec<u8>>, options: Option<DeleteOptions>, ) -> Result<DeleteResponse, Error>
Deletes the given key or a range of keys from the key-value store.
Sourcepub async fn compact(
&mut self,
revision: i64,
options: Option<CompactionOptions>,
) -> Result<CompactionResponse, Error>
pub async fn compact( &mut self, revision: i64, options: Option<CompactionOptions>, ) -> Result<CompactionResponse, Error>
Compacts the event history in the etcd key-value store. The key-value store should be periodically compacted or the event history will continue to grow indefinitely.
Sourcepub async fn txn(&mut self, txn: Txn) -> Result<TxnResponse, Error>
pub async fn txn(&mut self, txn: Txn) -> Result<TxnResponse, Error>
Processes multiple operations in a single transaction. A txn request increments the revision of the key-value store and generates events with the same revision for every completed operation. It is not allowed to modify the same key several times within one txn.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for KvClient
impl !RefUnwindSafe for KvClient
impl !UnwindSafe for KvClient
impl Send for KvClient
impl Sync for KvClient
impl Unpin for KvClient
impl UnsafeUnpin for KvClient
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