pub struct Client<S> { /* private fields */ }Expand description
Client struct to interact with a cluster for requests and subscriptions
S is the MembershipStorage implementation to fetch the cluster members
Implementations§
Source§impl<S> Client<S>where
S: 'static + MembershipStorage,
impl<S> Client<S>where
S: 'static + MembershipStorage,
Sourcepub async fn send<T, E>(
&mut self,
handler_type: impl AsRef<str>,
handler_id: impl AsRef<str>,
payload: &(impl Serialize + IdentifiableType + Send + Sync),
) -> Result<T, RequestError<E>>
pub async fn send<T, E>( &mut self, handler_type: impl AsRef<str>, handler_id: impl AsRef<str>, payload: &(impl Serialize + IdentifiableType + Send + Sync), ) -> Result<T, RequestError<E>>
Send a request to the cluster transparently (the caller doesn’t need to know where the object is placed)
TODO
When the cached or selected server are not available, it needs to refresh all the cache and try a different server, this process needs to repeat until it finds a new available server
Sourcepub async fn send_request<E: Error + DeserializeOwned + Clone + Send + Sync>(
&mut self,
request: RequestEnvelope,
) -> Result<Vec<u8>, RequestError<E>>
pub async fn send_request<E: Error + DeserializeOwned + Clone + Send + Sync>( &mut self, request: RequestEnvelope, ) -> Result<Vec<u8>, RequestError<E>>
Same as Self::send, but it uses the RequestEnvelope ready for serialization
Sourcepub async fn subscribe<'a, T>(
&'a mut self,
handler_type: impl AsRef<str>,
handler_id: impl AsRef<str>,
) -> Result<impl Stream<Item = Result<T, ResponseError>> + 'a, ClientError>
pub async fn subscribe<'a, T>( &'a mut self, handler_type: impl AsRef<str>, handler_id: impl AsRef<str>, ) -> Result<impl Stream<Item = Result<T, ResponseError>> + 'a, ClientError>
Subscribe to events from a service object
TODO
- Returns async iter
- Handle redirects
- Move this logic into a tower service
- Support moving service object (after you connect to a node and the handler you are listening to moves to some other node)
- Use dedicated connection
Sourcepub async fn ping(&mut self) -> Result<(), ClientError>
pub async fn ping(&mut self) -> Result<(), ClientError>
Connects to a the first server of the MembershipStorage
This is used mostly by the PeerToPeerClusterProvider to check whether a set of servers is reacheable and alive
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Client<S>where
S: Freeze,
impl<S> !RefUnwindSafe for Client<S>
impl<S> Send for Client<S>where
S: Send,
impl<S> Sync for Client<S>where
S: Sync,
impl<S> Unpin for Client<S>where
S: Unpin,
impl<S> UnsafeUnpin for Client<S>where
S: UnsafeUnpin,
impl<S> !UnwindSafe for Client<S>
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> 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> 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