pub struct ClientBuilder { /* private fields */ }
Expand description
Builder for Graphql over Websocket clients
This can be used to configure the client prior to construction, but can also create subscriptions directly in the case where users only need to run one per connection.
use graphql_ws_client::Client;
use std::future::IntoFuture;
let (client, actor) = Client::build(connection).await?;
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn payload<NewPayload>(
self,
payload: NewPayload,
) -> Result<ClientBuilder, Error>where
NewPayload: Serialize,
pub fn payload<NewPayload>(
self,
payload: NewPayload,
) -> Result<ClientBuilder, Error>where
NewPayload: Serialize,
Sourcepub fn subscription_buffer_size(self, new: usize) -> Self
pub fn subscription_buffer_size(self, new: usize) -> Self
Sets the size of the incoming message buffer that subscriptions created by this client will use
Sourcepub fn keep_alive_interval(self, new: Duration) -> Self
pub fn keep_alive_interval(self, new: Duration) -> Self
Sets the interval between keep alives.
Any incoming messages automatically reset this interval so keep alives may not be sent on busy connections even if this is set.
Sourcepub fn keep_alive_retries(self, count: usize) -> Self
pub fn keep_alive_retries(self, count: usize) -> Self
The number of keepalive retries before a connection is considered broken.
This defaults to 3, but has no effect if keep_alive_interval
is not called.
Sourcepub async fn subscribe<'a, Operation>(
self,
op: Operation,
) -> Result<Subscription<Operation>, Error>
pub async fn subscribe<'a, Operation>( self, op: Operation, ) -> Result<Subscription<Operation>, Error>
Initialise a Client and use it to run a single subscription
use graphql_ws_client::Client;
use std::future::IntoFuture;
let stream = Client::build(connection).subscribe(subscription).await?;
Note that this takes ownership of the client, so it cannot be used to run any more operations.
If users want to run multiple operations on a connection they
should use the IntoFuture
impl to construct a Client