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

Accumulate parameters for a new Sender instance.

use questdb::ingress::SenderBuilder;

let mut sender = SenderBuilder::new("localhost", 9009).connect()?;

Additional options for:

Implementations§

source§

impl SenderBuilder

source

pub fn new<H: Into<String>, P: Into<Service>>(host: H, port: P) -> Self

QuestDB server and port.

use questdb::ingress::SenderBuilder;

let mut sender = SenderBuilder::new("localhost", 9009).connect()?;
source

pub fn net_interface<I: Into<String>>(self, addr: I) -> Self

Select local outbound interface.

This may be relevant if your machine has multiple network interfaces.

If unspecified, the default is to use any available interface and is equivalent to calling:

let mut sender = SenderBuilder::new("localhost", 9009)
    .net_interface("0.0.0.0")
    .connect()?;
source

pub fn auth<A, B, C, D>( self, key_id: A, priv_key: B, pub_key_x: C, pub_key_y: D ) -> Self
where A: Into<String>, B: Into<String>, C: Into<String>, D: Into<String>,

Authentication Parameters.

If not called, authentication is disabled.

Arguments
  • key_id - Key identifier, AKA “kid” in JWT. This is sometimes referred to as the username.
  • priv_key - Private key, AKA “d” in JWT.
  • pub_key_x - X coordinate of the public key, AKA “x” in JWT.
  • pub_key_y - Y coordinate of the public key, AKA “y” in JWT.
Example
let mut sender = SenderBuilder::new("localhost", 9009)
    .auth(
        "testUser1",                                    // kid
        "5UjEMuA0Pj5pjK8a-fa24dyIf-Es5mYny3oE_Wmus48",  // d
        "fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU",  // x
        "Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac")  // y
    .connect()?;

Follow the QuestDB authentication documentation for instructions on generating keys.

source

pub fn tls(self, tls: Tls) -> Self

Configure TLS handshake.

The default is Tls::Disabled.

let mut sender = SenderBuilder::new("localhost", 9009)
    .tls(Tls::Disabled)
    .connect()?;

To enable with commonly accepted certificates, use:

use questdb::ingress::CertificateAuthority;

let mut sender = SenderBuilder::new("localhost", 9009)
    .tls(Tls::Enabled(CertificateAuthority::WebpkiRoots))
    .connect()?;

To use self-signed certificates:

use questdb::ingress::CertificateAuthority;
use std::path::PathBuf;

let mut sender = SenderBuilder::new("localhost", 9009)
    .tls(Tls::Enabled(CertificateAuthority::File(
        PathBuf::from("/path/to/server_rootCA.pem"))))
    .connect()?;

If you’re still struggling you may temporarily enable the dangerous insecure-skip-verify feature to skip the certificate verification:

let mut sender = SenderBuilder::new("localhost", 9009)
   .tls(Tls::InsecureSkipVerify)
   .connect()?;
source

pub fn read_timeout(self, value: Duration) -> Self

Configure how long to wait for messages from the QuestDB server during the TLS handshake and authentication process. The default is 15 seconds.

use std::time::Duration;

let mut sender = SenderBuilder::new("localhost", 9009)
   .read_timeout(Duration::from_secs(15))
   .connect()?;
source

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

Connect synchronously.

Will return 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.