Struct questdb::ingress::SenderBuilder
source · [−]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:
- Binding a specific outbound network address.
- Connection security (authentication, encryption).
- Authentication timeouts.
Implementations
sourceimpl SenderBuilder
impl SenderBuilder
sourcepub fn new<H: Into<String>, P: Into<Service>>(host: H, port: P) -> Self
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()?;
sourcepub fn net_interface<I: Into<String>>(self, addr: I) -> Self
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()?;
sourcepub fn auth<A, B, C, D>(
self,
key_id: A,
priv_key: B,
pub_key_x: C,
pub_key_y: D
) -> Selfwhere
A: Into<String>,
B: Into<String>,
C: Into<String>,
D: Into<String>,
pub fn auth<A, B, C, D>(
self,
key_id: A,
priv_key: B,
pub_key_x: C,
pub_key_y: D
) -> Selfwhere
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.
sourcepub fn tls(self, tls: Tls) -> Self
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()?;
sourcepub fn read_timeout(self, value: Duration) -> Self
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()?;
Trait Implementations
sourceimpl Clone for SenderBuilder
impl Clone for SenderBuilder
sourcefn clone(&self) -> SenderBuilder
fn clone(&self) -> SenderBuilder
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more