pub struct ClientBuilder { /* private fields */ }Expand description
Builds a ScopeDB client with an optional API key and custom HTTP client.
The API key is attached by the ScopeDB client itself, so callers can still provide a preconfigured reqwest client for TLS, proxy, timeout, and pooling settings.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn api_key(self, api_key: impl Into<String>) -> Self
pub fn api_key(self, api_key: impl Into<String>) -> Self
Sets the ScopeDB API key sent as a sensitive Bearer credential.
This per-request value takes precedence over an Authorization default
configured on the underlying HTTP client.
Examples found in repository?
34pub fn client() -> Result<Client, Box<dyn std::error::Error>> {
35 let api_key = std::env::var("SCOPEDB_API_KEY")
36 .ok()
37 .filter(|value| !value.is_empty())
38 .or_else(|| {
39 std::env::var("SCOPEDB_TOKEN")
40 .ok()
41 .filter(|value| !value.is_empty())
42 });
43 let mut builder = Client::builder(endpoint());
44 if let Some(api_key) = api_key {
45 builder = builder.api_key(api_key);
46 }
47 Ok(builder.build()?)
48}Sourcepub fn http_client(self, client: Client) -> Self
pub fn http_client(self, client: Client) -> Self
Uses a preconfigured compatible HTTP client.
Use the re-exported crate::reqwest version. Disable redirects and
transport retries to prevent replaying writes; the SDK’s default client
already does this.
use scopedb_client::reqwest;
let http_client = reqwest::Client::builder()
.redirect(reqwest::redirect::Policy::none())
.retry(reqwest::retry::never())
.build()?;Sourcepub fn write_timeout(self, timeout: Duration) -> Self
pub fn write_timeout(self, timeout: Duration) -> Self
Bounds each table append and Catalog mutation HTTP request, including
reading the response body. Defaults to 30 seconds and must be finite and nonzero.
This deadline cannot be disabled; increase it when writes need more time.
The budget starts after local encoding, compression, and request preparation.
Stream attempt_timeout settings override this default. A timeout does
not roll back the write; its commit outcome can be unknown.
This is a per-attempt budget. Waiting for stream capacity, retry backoff,
and the total duration of a flush or shutdown are outside it.
Append timeouts are exposed through Error::write_details and are
never automatically replayed.
Shorter timeouts on a custom HTTP client still apply.
Sourcepub fn build(self) -> Result<Client, Error>
pub fn build(self) -> Result<Client, Error>
Validates the endpoint and authentication settings and builds the client.
Examples found in repository?
34pub fn client() -> Result<Client, Box<dyn std::error::Error>> {
35 let api_key = std::env::var("SCOPEDB_API_KEY")
36 .ok()
37 .filter(|value| !value.is_empty())
38 .or_else(|| {
39 std::env::var("SCOPEDB_TOKEN")
40 .ok()
41 .filter(|value| !value.is_empty())
42 });
43 let mut builder = Client::builder(endpoint());
44 if let Some(api_key) = api_key {
45 builder = builder.api_key(api_key);
46 }
47 Ok(builder.build()?)
48}