Struct SenderBuilder

Source
pub struct SenderBuilder { /* private fields */ }
Expand description

Accumulates parameters for a new Sender instance.

You can also create the builder 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 the configuration string.

The format of the string is: "http::addr=host:port;key=value;...;".

Instead of "http", you can also specify "https", "tcp", and "tcps".

We recommend HTTP for most cases because it provides more features, like reporting errors to the client and supporting transaction control. TCP can sometimes be faster in higher-latency networks, but misses a number of features.

The accepted keys match one-for-one with the methods on SenderBuilder. For example, this is a valid configuration string:

“https::addr=host:port;username=alice;password=secret;”

and there are matching methods SenderBuilder::username and SenderBuilder::password. The value of addr= is supplied directly to the SenderBuilder constructor, so there’s no matching method for that.

You can also load the configuration from an environment variable. See SenderBuilder::from_env.

Once you have a SenderBuilder instance, you can further customize it before calling SenderBuilder::build, but you can’t change any settings that are already set in the config string.

Source

pub fn from_env() -> Result<Self>

Create a new SenderBuilder instance from the configuration from the configuration stored in 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 with 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 a part of basic authentication. See also: password.

Source

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

Set the password for basic HTTP authentication. See also: username.

Source

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

Set the Token (Bearer) Authentication parameter for HTTP, or the ECDSA private key for TCP authentication.

Source

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

Set the ECDSA public key X for TCP authentication.

Source

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

Set the ECDSA public key Y for 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. This only applies to TCP. 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 in bytes that the client will flush to the server. The default is 100 MiB.

Source

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

Set the cumulative duration spent in retries. The value is in milliseconds, and the default is 10 seconds.

Source

pub fn request_min_throughput(self, value: u64) -> Result<Self>

Set the minimum acceptable throughput while sending a buffer to the server. The sender will divide the payload size by this number to determine for how long to keep sending the payload before timing out. The value is in bytes per second, and the default is 100 KiB/s. The timeout calculated from minimum throughput is adedd to the value of request_timeout to get the total timeout value. A value of 0 disables this feature, so it’s similar to setting “infinite” minimum throughput. The total timeout will then be equal to request_timeout.

Source

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

Additional time to wait on top of that calculated from the minimum throughput. This accounts for the fixed latency of the HTTP request-response roundtrip. The default is 10 seconds. See also: request_min_throughput.

Source

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

Build the sender.

In the 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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