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

source

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.

source

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.

source

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()?;
source

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".

source

pub fn username(self, username: &str) -> Result<Self>

Set the username for authentication.

For TCP this is the kid part of the ECDSA key set. The other fields are token, token_x, and token_y.

For HTTP this is part of basic authentication. Also see password.

source

pub fn password(self, password: &str) -> Result<Self>

Set the password for basic HTTP authentication. Also see username.

source

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.

source

pub fn token_x(self, token_x: &str) -> Result<Self>

The ECDSA public key X for ILP over TCP authentication.

source

pub fn token_y(self, token_y: &str) -> Result<Self>

The ECDSA public key Y for ILP over TCP authentication.

source

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.

source

pub fn ensure_tls_enabled(&self, property: &str) -> Result<()>

Ensure that TLS is enabled for the protocol.

source

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.

source

pub fn tls_ca(self, ca: CertificateAuthority) -> Result<Self>

Specify where to find the root certificate used to validate the server’s TLS certificate.

source

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.

source

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.

source

pub fn retry_timeout(self, value: Duration) -> Result<Self>

Cumulative duration spent in retries. The default is 10 seconds.

source

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.

source

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.

source

pub fn build(&self) -> Result<Sender>

Build the sender.

In case of TCP, this synchronously establishes the TCP connection, and returns once the connection is fully established. If the connection requires authentication or TLS, these will also be completed before returning.

Trait Implementations§

source§

impl Clone for SenderBuilder

source§

fn clone(&self) -> SenderBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SenderBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V