pub struct Client { /* private fields */ }Expand description
可向任意本地节点提交请求的客户端(跟随者会转发到领导者)。
Implementations§
Source§impl Client
impl Client
Sourcepub fn register_node(
&self,
id: NodeID,
tx: Sender<(Request, Sender<Result<Response>>)>,
)
pub fn register_node( &self, id: NodeID, tx: Sender<(Request, Sender<Result<Response>>)>, )
注册或更新某节点的请求通道(节点 start 后调用)。
pub fn unregister_node(&self, id: NodeID)
Sourcepub fn preferred_hint(&mut self, id: NodeID)
pub fn preferred_hint(&mut self, id: NodeID)
提示下次优先向该节点发请求。
pub fn request(&mut self, request: Request) -> Result<Response>
Sourcepub fn request_on(
&mut self,
node_id: NodeID,
request: Request,
) -> Result<Response>
pub fn request_on( &mut self, node_id: NodeID, request: Request, ) -> Result<Response>
只向指定节点发请求(仍在 Abort 时对该节点重试)。
pub fn put(&mut self, key: &str, value: &str) -> Result<Index>
pub fn put_on( &mut self, node_id: NodeID, key: &str, value: &str, ) -> Result<Index>
pub fn get(&mut self, key: &str) -> Result<Option<String>>
pub fn scan(&mut self) -> Result<BTreeMap<String, String>>
pub fn status(&mut self) -> Result<Status>
pub fn status_on(&mut self, node_id: NodeID) -> Result<Status>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl UnwindSafe for Client
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more