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 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 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.
Source§impl ClientFactory
impl ClientFactory
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 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 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