pub struct ClientOptions {
pub username: String,
pub password: Secret,
pub default_database: String,
pub domain: Option<String>,
pub ipv4_only: bool,
pub cafile: Option<PathBuf>,
pub use_tls: bool,
pub compression: CompressionMethod,
pub ext: Extension,
}
Expand description
Configuration options for a ClickHouse
client connection and Arrow serialization.
The ClientOptions
struct defines the settings used to establish a connection
to a ClickHouse
server and handle data serialization/deserialization with
Apache Arrow. These options are typically set via super::builder::ClientBuilder
methods
(e.g., super::builder::ClientBuilder::with_username
,
super::builder::ClientBuilder::with_tls
) or constructed directly for use with
crate::Client::connect
.
§Fields
username
: The username for authenticating withClickHouse
(default:"default"
).password
: The password for authentication, stored securely as aSecret
.default_database
: The default database for queries; if empty, usesClickHouse
’s"default"
database.domain
: Optional domain for TLS verification; inferred from the destination if unset.ipv4_only
: Iftrue
, restricts address resolution to IPv4; iffalse
, allows IPv6.cafile
: Optional path to a certificate authority file for TLS connections.use_tls
: Iftrue
, enables TLS for secure connections; iffalse
, uses plain TCP.compression
: The compression method for data exchange (default:CompressionMethod::LZ4
).arrow
: Optional Arrow-specific serialization options (seeArrowOptions
).cloud
: Cloud-specific options forClickHouse
cloud instances (requirescloud
feature).
§Examples
use clickhouse_arrow::prelude::*;
let options = ClientOptions {
username: "admin".to_string(),
password: Secret::new("secret"),
default_database: "my_db".to_string(),
use_tls: true,
..ClientOptions::default()
};
let client = Client::connect("localhost:9000", options, None, None)
.await
.unwrap();
Fields§
§username: String
Username credential
password: Secret
Password credential. Secret
is used to minimize likelihood of exposure through logs
default_database: String
Scope this client to a specifc database, otherwise ‘default’ is used
domain: Option<String>
For tls, provide the domain, otherwise it will be determined from the endpoint.
ipv4_only: bool
Whether any non-ipv4 socket addrs should be filtered out.
cafile: Option<PathBuf>
Provide a path to a certificate authority to use for tls.
use_tls: bool
Whether a connection should be made securely over tls.
compression: CompressionMethod
The compression to use when sending data to clickhouse.
ext: Extension
Additional configuration not core to ClickHouse
connections
Implementations§
Source§impl ClientOptions
impl ClientOptions
pub fn with_username(self, username: impl Into<String>) -> Self
pub fn with_password(self, password: impl Into<Secret>) -> Self
pub fn with_default_database(self, default_database: impl Into<String>) -> Self
pub fn with_domain(self, domain: impl Into<String>) -> Self
pub fn with_ipv4_only(self, ipv4_only: bool) -> Self
pub fn with_cafile<P: AsRef<Path>>(self, cafile: P) -> Self
pub fn with_use_tls(self, use_tls: bool) -> Self
pub fn with_compression(self, compression: CompressionMethod) -> Self
pub fn with_extension(self, ext: Extension) -> Self
pub fn extend(self, ext: impl Fn(Extension) -> Extension) -> Self
Trait Implementations§
Source§impl Clone for ClientOptions
impl Clone for ClientOptions
Source§fn clone(&self) -> ClientOptions
fn clone(&self) -> ClientOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more