Struct conjure_runtime::ClientFactory
source · [−]pub struct ClientFactory { /* private fields */ }Expand description
A factory type which can create clients that will live-reload in response to configuration updates.
Implementations
sourceimpl ClientFactory
impl ClientFactory
sourcepub fn new(config: Refreshable<ServicesConfig, Error>) -> ClientFactory
pub fn new(config: Refreshable<ServicesConfig, Error>) -> ClientFactory
Creates a new client factory based off of a refreshable ServicesConfig.
sourcepub fn user_agent(&mut self, user_agent: UserAgent) -> &mut Self
pub fn user_agent(&mut self, user_agent: UserAgent) -> &mut Self
Sets the user agent sent by clients.
Required.
sourcepub fn get_user_agent(&self) -> Option<&UserAgent>
pub fn get_user_agent(&self) -> Option<&UserAgent>
Returns the configured user agent.
sourcepub fn client_qos(&mut self, client_qos: ClientQos) -> &mut Self
pub fn client_qos(&mut self, client_qos: ClientQos) -> &mut 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(&mut self, server_qos: ServerQos) -> &mut Self
pub fn server_qos(&mut self, server_qos: ServerQos) -> &mut 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(&mut self, service_error: ServiceError) -> &mut Self
pub fn service_error(&mut self, service_error: ServiceError) -> &mut 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(&mut self, idempotency: Idempotency) -> &mut Self
pub fn idempotency(&mut self, idempotency: Idempotency) -> &mut 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(
&mut self,
node_selection_strategy: NodeSelectionStrategy
) -> &mut Self
pub fn node_selection_strategy(
&mut self,
node_selection_strategy: NodeSelectionStrategy
) -> &mut 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(&mut self, metrics: Arc<MetricRegistry>) -> &mut Self
pub fn metrics(&mut self, metrics: Arc<MetricRegistry>) -> &mut 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(
&mut self,
host_metrics: Arc<HostMetricsRegistry>
) -> &mut Self
pub fn host_metrics(
&mut self,
host_metrics: Arc<HostMetricsRegistry>
) -> &mut 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(&mut self, blocking_handle: Handle) -> &mut Self
pub fn blocking_handle(&mut self, blocking_handle: Handle) -> &mut 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.
Panics
Panics if user_agent is not set.
sourcepub fn blocking_client<T>(&self, service: &str) -> Result<T, Error>where
T: Service<Client>,
pub fn blocking_client<T>(&self, service: &str) -> Result<T, Error>where
T: Service<Client>,
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.
Panics
Panics if user_agent is not set.
Trait Implementations
sourceimpl Clone for ClientFactory
impl Clone for ClientFactory
sourcefn clone(&self) -> ClientFactory
fn clone(&self) -> ClientFactory
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more