pub struct RqliteClientBuilder { /* private fields */ }
Expand description
A builder for creating a RqliteClient
.
Implementations§
Source§impl RqliteClientBuilder
impl RqliteClientBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new RqliteClientBuilder
.
Sourcepub fn known_host(self, host: impl ToString) -> Self
pub fn known_host(self, host: impl ToString) -> Self
Adds a known host to the builder.
It is important not to add the scheme to the host.
The scheme is set using the scheme
method.
The host should be in the format hostname:port
.
For example, localhost:4001
.
Sourcepub fn default_query_params(self, params: Vec<RqliteQueryParam>) -> Self
pub fn default_query_params(self, params: Vec<RqliteQueryParam>) -> Self
Adds a default query parameter to the builder.
The blob_array
parameter is added by default if the fast-blob
feature is not enabled. (see https://rqlite.io/docs/api/api/#blob-data)
Sourcepub fn fallback_count(self, count: FallbackCount) -> Self
pub fn fallback_count(self, count: FallbackCount) -> Self
Sets the fallback count for the client. The fallback count is the number of times the client will try to switch to another host if the current host fails.
Sourcepub fn fallback_strategy(
self,
strategy: impl FallbackStrategy + 'static,
) -> Self
pub fn fallback_strategy( self, strategy: impl FallbackStrategy + 'static, ) -> Self
Sets the fallback strategy for the client.
The fallback strategy is the strategy used to switch to another host if the current host fails.
The default strategy is RoundRobin
.
Sourcepub fn fallback_persistence(self, persist: bool) -> Self
pub fn fallback_persistence(self, persist: bool) -> Self
Sets the fallback persistence for the client.
If set to true
, which is the default, the client will keep using the last host that was successful.
If set to false
, the client will always try the first host in the list.
Sourcepub fn build(self) -> Result<RqliteClient, ClientBuilderError>
pub fn build(self) -> Result<RqliteClient, ClientBuilderError>
Builds the RqliteClient
with the provided hosts.
§Errors
This function will return an error if:
- No hosts were provided
- Failed to create HTTP client
- Invalid authorization header