pub struct Client<E, VER: StaticVersionType> { /* private fields */ }Expand description
A client of a Tide Disco application.
Implementations§
Source§impl<E: Error, VER: StaticVersionType> Client<E, VER>
impl<E: Error, VER: StaticVersionType> Client<E, VER>
Sourcepub fn new(base_url: Url) -> Self
pub fn new(base_url: Url) -> Self
Create a client and connect to the Tide Disco server at base_url.
Sourcepub fn builder(base_url: Url) -> ClientBuilder<E, VER>
pub fn builder(base_url: Url) -> ClientBuilder<E, VER>
Create a client with customization.
Sourcepub async fn connect(&self, timeout: Option<Duration>) -> bool
pub async fn connect(&self, timeout: Option<Duration>) -> bool
Connect to the server, retrying if the server is not running.
It is not necessary to call this function when creating a new client. The client will automatically connect when a request is made, if the server is available. However, this can be useful to wait for the server to come up, if the server may be offline when the client is created.
This function will make an HTTP GET request to the server’s /healthcheck endpoint, to
test if the server is available. If this request succeeds, connect returns
true. Otherwise, the client will continue retrying /healthcheck requests until timeout
has elapsed (or forever, if timeout is None). If the timeout expires before a
/healthcheck request succeeds, connect will return false.
Sourcepub async fn wait_for_health<H: DeserializeOwned + HealthCheck>(
&self,
healthy: impl Fn(&H) -> bool,
timeout: Option<Duration>,
) -> Option<H>
pub async fn wait_for_health<H: DeserializeOwned + HealthCheck>( &self, healthy: impl Fn(&H) -> bool, timeout: Option<Duration>, ) -> Option<H>
Connect to the server, retrying until the server is healthy.
This function is similar to connect. It will make requests to the
/healthcheck endpoint until a request succeeds. However, it will then continue retrying
until the response from /healthcheck satisfies the healthy predicate.
On success, returns the response from /healthcheck. On timeout, returns None.
Sourcepub fn get<T: DeserializeOwned>(&self, route: &str) -> Request<T, E, VER>
pub fn get<T: DeserializeOwned>(&self, route: &str) -> Request<T, E, VER>
Build an HTTP GET request.
Sourcepub fn post<T: DeserializeOwned>(&self, route: &str) -> Request<T, E, VER>
pub fn post<T: DeserializeOwned>(&self, route: &str) -> Request<T, E, VER>
Build an HTTP POST request.
Sourcepub async fn healthcheck<H: DeserializeOwned + HealthCheck>(
&self,
) -> Result<H, E>
pub async fn healthcheck<H: DeserializeOwned + HealthCheck>( &self, ) -> Result<H, E>
Query the server’s healthcheck endpoint.
Sourcepub fn request<T: DeserializeOwned>(
&self,
method: Method,
route: &str,
) -> Request<T, E, VER>
pub fn request<T: DeserializeOwned>( &self, method: Method, route: &str, ) -> Request<T, E, VER>
Build an HTTP request with the specified method.
Sourcepub fn socket(&self, route: &str) -> SocketRequest<E, VER>
pub fn socket(&self, route: &str) -> SocketRequest<E, VER>
Sourcepub fn socket_with_config(
&self,
route: &str,
config: WebSocketConfig,
) -> SocketRequest<E, VER>
pub fn socket_with_config( &self, route: &str, config: WebSocketConfig, ) -> SocketRequest<E, VER>
Build a streaming connection request using a custom WebSocketConfig.
§Panics
This will panic if a malformed URL is passed.
Sourcepub fn module<ModError: Error>(
&self,
prefix: &str,
) -> Result<Client<ModError, VER>, ParseError>
pub fn module<ModError: Error>( &self, prefix: &str, ) -> Result<Client<ModError, VER>, ParseError>
Create a client for a sub-module of the connected application.
pub fn base_url(&self) -> Url
Trait Implementations§
Source§impl<E: Error, VER: StaticVersionType> From<ClientBuilder<E, VER>> for Client<E, VER>
impl<E: Error, VER: StaticVersionType> From<ClientBuilder<E, VER>> for Client<E, VER>
Source§fn from(builder: ClientBuilder<E, VER>) -> Self
fn from(builder: ClientBuilder<E, VER>) -> Self
Auto Trait Implementations§
impl<E, VER> Freeze for Client<E, VER>
impl<E, VER> !RefUnwindSafe for Client<E, VER>
impl<E, VER> Send for Client<E, VER>
impl<E, VER> Sync for Client<E, VER>
impl<E, VER> Unpin for Client<E, VER>
impl<E, VER> !UnwindSafe for Client<E, VER>
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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