Struct conjure_runtime::ClientFactory
source · pub struct ClientFactory<T = Complete>(/* private fields */);
Expand description
A factory type which can create clients that will live-reload in response to configuration updates.
Implementations§
source§impl ClientFactory<ConfigStage>
impl ClientFactory<ConfigStage>
sourcepub fn config(
self,
config: Refreshable<ServicesConfig, Error>
) -> ClientFactory<UserAgentStage>
pub fn config( self, config: Refreshable<ServicesConfig, Error> ) -> ClientFactory<UserAgentStage>
Sets the refreshable configuration used for service clients.
source§impl ClientFactory<UserAgentStage>
impl ClientFactory<UserAgentStage>
sourcepub fn user_agent(self, user_agent: UserAgent) -> ClientFactory
pub fn user_agent(self, user_agent: UserAgent) -> ClientFactory
Sets the user agent sent by clients.
source§impl ClientFactory
impl ClientFactory
sourcepub fn user_agent(self, user_agent: UserAgent) -> Self
pub fn user_agent(self, user_agent: UserAgent) -> Self
Sets the user agent sent by clients.
sourcepub fn get_user_agent(&self) -> &UserAgent
pub fn get_user_agent(&self) -> &UserAgent
Returns the configured user agent.
sourcepub fn client_qos(self, client_qos: ClientQos) -> Self
pub fn client_qos(self, client_qos: ClientQos) -> Self
Sets clients’ rate limiting behavior.
Defaults to ClientQos::Enabled
.
sourcepub fn get_client_qos(&self) -> ClientQos
pub fn get_client_qos(&self) -> ClientQos
Returns the configured rate limiting behavior
sourcepub fn server_qos(self, server_qos: ServerQos) -> Self
pub fn server_qos(self, server_qos: ServerQos) -> Self
Sets clients’ behavior in response to a QoS error from the server.
Defaults to ServerQos::AutomaticRetry
.
sourcepub fn get_server_qos(&self) -> ServerQos
pub fn get_server_qos(&self) -> ServerQos
Returns the configured QoS behavior.
sourcepub fn service_error(self, service_error: ServiceError) -> Self
pub fn service_error(self, service_error: ServiceError) -> Self
Sets clients’ behavior in response to a service error from the server.
Defaults to ServiceError::WrapInNewError
.
sourcepub fn get_service_error(&self) -> ServiceError
pub fn get_service_error(&self) -> ServiceError
Returns the configured service error behavior.
sourcepub fn idempotency(self, idempotency: Idempotency) -> Self
pub fn idempotency(self, idempotency: Idempotency) -> Self
Sets clients’ behavior to determine if a request is idempotent or not.
Only idempotent requests will be retried.
Defaults to Idempotency::ByMethod
.
sourcepub fn get_idempotency(&self) -> Idempotency
pub fn get_idempotency(&self) -> Idempotency
Returns the configured idempotency behavior.
sourcepub fn node_selection_strategy(
self,
node_selection_strategy: NodeSelectionStrategy
) -> Self
pub fn node_selection_strategy( self, node_selection_strategy: NodeSelectionStrategy ) -> Self
Sets the clients’ strategy for selecting a node for a request.
Defaults to NodeSelectionStrategy::PinUntilError
.
sourcepub fn get_node_selection_strategy(&self) -> NodeSelectionStrategy
pub fn get_node_selection_strategy(&self) -> NodeSelectionStrategy
Returns the configured node selection strategy.
sourcepub fn metrics(self, metrics: Arc<MetricRegistry>) -> Self
pub fn metrics(self, metrics: Arc<MetricRegistry>) -> Self
Sets the metric registry used to register client metrics.
Defaults to no registry.
sourcepub fn get_metrics(&self) -> Option<&Arc<MetricRegistry>>
pub fn get_metrics(&self) -> Option<&Arc<MetricRegistry>>
Returns the configured metrics registry.
sourcepub fn host_metrics(self, host_metrics: Arc<HostMetricsRegistry>) -> Self
pub fn host_metrics(self, host_metrics: Arc<HostMetricsRegistry>) -> Self
Sets the host metrics registry used to track host performance.
Defaults to no registry.
sourcepub fn get_host_metrics(&self) -> Option<&Arc<HostMetricsRegistry>>
pub fn get_host_metrics(&self) -> Option<&Arc<HostMetricsRegistry>>
Returns the configured host metrics registry.
sourcepub fn blocking_handle(self, blocking_handle: Handle) -> Self
pub fn blocking_handle(self, blocking_handle: Handle) -> Self
Returns the Handle
to the tokio Runtime
to be used by blocking clients.
This has no effect on async clients.
Defaults to a conjure-runtime
internal Runtime
.
sourcepub fn get_blocking_handle(&self) -> Option<&Handle>
pub fn get_blocking_handle(&self) -> Option<&Handle>
Returns the configured blocking handle.
sourcepub fn client<T>(&self, service: &str) -> Result<T, Error>where
T: AsyncService<Client>,
pub fn client<T>(&self, service: &str) -> Result<T, Error>where
T: AsyncService<Client>,
Creates a new client for the specified service.
The client’s configuration will automatically refresh to track changes in the factory’s ServicesConfig
.
If no configuration is present for the specified service in the ServicesConfig
, the client will
immediately return an error for all requests.
The method can return any type implementing the conjure-http
AsyncService
trait. This notably includes all
Conjure-generated client types as well as the conjure-runtime
Client
itself.
sourcepub fn blocking_client<T>(&self, service: &str) -> Result<T, Error>
pub fn blocking_client<T>(&self, service: &str) -> Result<T, Error>
Creates a new blocking client for the specified service.
The client’s configuration will automatically refresh to track changes in the factory’s ServicesConfig
.
If no configuration is present for the specified service in the ServicesConfig
, the client will
immediately return an error for all requests.
The method can return any type implementing the conjure-http
Service
trait. This notably includes all
Conjure-generated client types as well as the conjure-runtime
blocking::Client
itself.
sourcepub fn per_host_clients<T>(
&self,
service: &str
) -> Result<Refreshable<PerHostClients<T>, Error>, Error>
pub fn per_host_clients<T>( &self, service: &str ) -> Result<Refreshable<PerHostClients<T>, Error>, Error>
Creates a refreshable collection of clients, each corresponding to a separate replica of the service.
§Note
The client type T
is assumed to be stateless - each instance will be recreated on every
refresh.
sourcepub fn blocking_per_host_clients<T>(
&self,
service: &str
) -> Result<Refreshable<PerHostClients<T>, Error>, Error>
pub fn blocking_per_host_clients<T>( &self, service: &str ) -> Result<Refreshable<PerHostClients<T>, Error>, Error>
Creates a refreshable collection of blocking clients, each corresponding to a separate replica of the service.
§Note
The client type T
is assumed to be stateless - each instance will be recreated on every
refresh.
Trait Implementations§
source§impl<T: Clone> Clone for ClientFactory<T>
impl<T: Clone> Clone for ClientFactory<T>
source§fn clone(&self) -> ClientFactory<T>
fn clone(&self) -> ClientFactory<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more