Struct questdb::ingress::SenderBuilder
source · pub struct SenderBuilder { /* private fields */ }Expand description
Accumulate parameters for a new Sender instance.
The SenderBuilder can be created either for ILP/TCP or ILP/HTTP (with the “ilp-over-http”
feature enabled).
It can also be created from a config string or the QDB_CLIENT_CONF environment variable.
use questdb::ingress::{Protocol, SenderBuilder};
let mut sender = SenderBuilder::new(Protocol::Http, "localhost", 9009).build()?;use questdb::ingress::{Protocol, SenderBuilder};
let mut sender = SenderBuilder::new(Protocol::Tcp, "localhost", 9009).build()?;use questdb::ingress::SenderBuilder;
let mut sender = SenderBuilder::from_conf("https::addr=localhost:9000;")?.build()?;use questdb::ingress::SenderBuilder;
// export QDB_CLIENT_CONF="https::addr=localhost:9000;"
let mut sender = SenderBuilder::from_env()?.build()?;Implementations§
source§impl SenderBuilder
impl SenderBuilder
sourcepub fn from_conf<T: AsRef<str>>(conf: T) -> Result<Self>
pub fn from_conf<T: AsRef<str>>(conf: T) -> Result<Self>
Create a new SenderBuilder instance from configuration string.
The format of the string is: "http::addr=host:port;key=value;...;".
Alongside "http" you can also specify "https", "tcp", and "tcps".
HTTP is recommended in most cases as is provides better error feedback allows controlling transactions. TCP can sometimes be faster in higher-latency networks, but misses out on a number of features.
The accepted set of keys and values is the same as for the SenderBuilder’s API.
E.g. "https::addr=host:port;username=alice;password=secret;tls_ca=os_roots;".
If you prefer, you can also load the configuration from an environment variable.
See SenderBuilder::from_env.
Once a SenderBuilder is created from a string (or from the environment variable)
it can be further customized before calling SenderBuilder::build.
sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Create a new SenderBuilder instance from configuration string read from the
QDB_CLIENT_CONF environment variable.
The format of the string is the same as for SenderBuilder::from_conf.
sourcepub fn new<H: Into<String>, P: Into<Port>>(
protocol: Protocol,
host: H,
port: P
) -> Self
pub fn new<H: Into<String>, P: Into<Port>>( protocol: Protocol, host: H, port: P ) -> Self
Create a new SenderBuilder instance from the provided QuestDB
server and port using ILP over the specified protocol.
use questdb::ingress::{Protocol, SenderBuilder};
let mut sender = SenderBuilder::new(
Protocol::Tcp, "localhost", 9009).build()?;sourcepub fn bind_interface<I: Into<String>>(self, addr: I) -> Result<Self>
pub fn bind_interface<I: Into<String>>(self, addr: I) -> Result<Self>
Select local outbound interface.
This may be relevant if your machine has multiple network interfaces.
The default is "0.0.0.0".
sourcepub fn password(self, password: &str) -> Result<Self>
pub fn password(self, password: &str) -> Result<Self>
Set the password for basic HTTP authentication.
Also see username.
sourcepub fn token(self, token: &str) -> Result<Self>
pub fn token(self, token: &str) -> Result<Self>
Token (Bearer) Authentication Parameters for ILP over HTTP, or the ECDSA private key for ILP over TCP authentication.
sourcepub fn token_x(self, token_x: &str) -> Result<Self>
pub fn token_x(self, token_x: &str) -> Result<Self>
The ECDSA public key X for ILP over TCP authentication.
sourcepub fn token_y(self, token_y: &str) -> Result<Self>
pub fn token_y(self, token_y: &str) -> Result<Self>
The ECDSA public key Y for ILP over TCP authentication.
sourcepub fn auth_timeout(self, value: Duration) -> Result<Self>
pub fn auth_timeout(self, value: Duration) -> Result<Self>
Configure how long to wait for messages from the QuestDB server during the TLS handshake and authentication process. The default is 15 seconds.
sourcepub fn ensure_tls_enabled(&self, property: &str) -> Result<()>
pub fn ensure_tls_enabled(&self, property: &str) -> Result<()>
Ensure that TLS is enabled for the protocol.
sourcepub fn tls_verify(self, verify: bool) -> Result<Self>
pub fn tls_verify(self, verify: bool) -> Result<Self>
Set to false to disable TLS certificate verification.
This should only be used for debugging purposes as it reduces security.
For testing consider specifying a path to a .pem file instead via
the tls_roots method.
sourcepub fn tls_ca(self, ca: CertificateAuthority) -> Result<Self>
pub fn tls_ca(self, ca: CertificateAuthority) -> Result<Self>
Specify where to find the root certificate used to validate the server’s TLS certificate.
sourcepub fn tls_roots<P: Into<PathBuf>>(self, path: P) -> Result<Self>
pub fn tls_roots<P: Into<PathBuf>>(self, path: P) -> Result<Self>
Set the path to a custom root certificate .pem file.
This is used to validate the server’s certificate during the TLS handshake.
See notes on how to test with self-signed certificates.
sourcepub fn max_buf_size(self, value: usize) -> Result<Self>
pub fn max_buf_size(self, value: usize) -> Result<Self>
The maximum buffer size that the client will flush to the server. The default is 100 MiB.
sourcepub fn retry_timeout(self, value: Duration) -> Result<Self>
pub fn retry_timeout(self, value: Duration) -> Result<Self>
Cumulative duration spent in retries. The default is 10 seconds.
sourcepub fn request_min_throughput(self, value: u64) -> Result<Self>
pub fn request_min_throughput(self, value: u64) -> Result<Self>
Minimum expected throughput in bytes per second for HTTP requests.
If the throughput is lower than this value, the connection will time out.
The default is 100 KiB/s.
The value is expressed as a number of bytes per second.
This is used to calculate additional request timeout, on top of
the request_timeout.
sourcepub fn request_timeout(self, value: Duration) -> Result<Self>
pub fn request_timeout(self, value: Duration) -> Result<Self>
Grace request timeout before relying on the minimum throughput logic.
The default is 10 seconds.
See request_min_throughput for more details.
Trait Implementations§
source§impl Clone for SenderBuilder
impl Clone for SenderBuilder
source§fn clone(&self) -> SenderBuilder
fn clone(&self) -> SenderBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more