pub struct StreamClientBuilder { /* private fields */ }Expand description
Builder for a StreamClient.
Debug is hand-written to redact the bearer token (and never leak TLS key
material) — never derive it here.
Implementations§
Source§impl StreamClientBuilder
impl StreamClientBuilder
Sourcepub fn bearer_token(self, token: impl Into<String>) -> Self
pub fn bearer_token(self, token: impl Into<String>) -> Self
Attach a bearer token, sent as authorization: Bearer <token> metadata
on every RPC.
The token is only honored when the server enforces auth
(-eventsgrpcauth); a no-auth (loopback-trust) server ignores it.
The endpoint must be encrypted. connect returns
StreamError::InsecureCredential for a token combined with a
non-https:// endpoint rather than putting it on the wire in the clear.
Pair this with tls or tls_ca_pem,
or use insecure_bearer_token to accept
the risk explicitly.
Sourcepub fn insecure_bearer_token(self, token: impl Into<String>) -> Self
pub fn insecure_bearer_token(self, token: impl Into<String>) -> Self
Like bearer_token, but permits sending the token
over an unencrypted endpoint.
Only for loopback and test harnesses. Over anything else the token is readable by every host on the path, and so is everything the stream carries — including the BIP 352 scan keys a Tier 2 watch registers, which disclose which outputs belong to the receiver.
This is a separate method rather than a flag so that the unsafe choice
has to be named at the call site, and so that a later switch back to
bearer_token cannot silently leave the waiver
behind.
Sourcepub fn keepalive(self, interval_secs: u64, timeout_secs: u64) -> Self
pub fn keepalive(self, interval_secs: u64, timeout_secs: u64) -> Self
Configure client-side HTTP/2 keepalive. Defaults match the server
(30s interval / 20s timeout) when keepalive_default
is used; this overrides with explicit seconds.
Sourcepub fn keepalive_default(self) -> Self
pub fn keepalive_default(self) -> Self
Use the server-matching keepalive defaults (30s interval / 20s timeout).
Sourcepub fn allow_old_node(self) -> Self
pub fn allow_old_node(self) -> Self
Accept a node two or more minor versions older than this SDK.
By default subscribe and
watch refuse such a node with
StreamError::NodeTooOld. With this set they log the same warning as
for a node one minor version behind and carry on. Meant for a rolling
upgrade where the SDK side went first. Features added after the node’s
release are still unavailable, and request fields it does not recognise
are still ignored.
This does not bypass StreamError::SchemaMismatch.
Sourcepub fn tls(self) -> Self
Available on crate feature tls only.
pub fn tls(self) -> Self
tls only.Enable TLS for the connection, trusting the bundled Mozilla root CAs
(for a server with a publicly-trusted certificate). For a private or
self-signed CA — the usual case for a satd node — use
tls_ca_pem instead. Requires the tls feature
(on by default).
Sourcepub fn tls_ca_pem(self, pem: impl Into<Vec<u8>>) -> Self
Available on crate feature tls only.
pub fn tls_ca_pem(self, pem: impl Into<Vec<u8>>) -> Self
tls only.Enable TLS and verify the server certificate against the PEM CA (or
self-signed leaf) in pem — the usual choice for a satd node serving its
own certificate. Replaces the bundled roots for this connection.
Sourcepub fn tls_client_identity(
self,
cert_pem: impl Into<Vec<u8>>,
key_pem: impl Into<Vec<u8>>,
) -> Self
Available on crate feature tls only.
pub fn tls_client_identity( self, cert_pem: impl Into<Vec<u8>>, key_pem: impl Into<Vec<u8>>, ) -> Self
tls only.Enable mutual TLS: present this PEM client certificate + private key to a
server configured for mTLS (-eventsgrpcmtls). Combine with
tls_ca_pem to pin the server’s CA — without it the
server certificate is verified against the bundled public Mozilla roots,
so a self-signed satd node (the usual mTLS case) will fail the handshake
unless you also call tls_ca_pem.
Sourcepub fn tls_domain(self, domain: impl Into<String>) -> Self
Available on crate feature tls only.
pub fn tls_domain(self, domain: impl Into<String>) -> Self
tls only.Override the certificate domain name verified during the TLS handshake (SNI). Use when the endpoint host differs from the certificate subject — e.g. connecting by IP, or through a proxy. Enables TLS if not already.
Sourcepub async fn connect(self) -> Result<StreamClient, StreamError>
pub async fn connect(self) -> Result<StreamClient, StreamError>
Connect the transport and return a ready StreamClient.
Trait Implementations§
Source§impl Clone for StreamClientBuilder
impl Clone for StreamClientBuilder
Auto Trait Implementations§
impl Freeze for StreamClientBuilder
impl RefUnwindSafe for StreamClientBuilder
impl Send for StreamClientBuilder
impl Sync for StreamClientBuilder
impl Unpin for StreamClientBuilder
impl UnsafeUnpin for StreamClientBuilder
impl UnwindSafe for StreamClientBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request