Skip to main content

StreamClientBuilder

Struct StreamClientBuilder 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn keepalive_default(self) -> Self

Use the server-matching keepalive defaults (30s interval / 20s timeout).

Source

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.

Source

pub fn tls(self) -> Self

Available on crate feature 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).

Source

pub fn tls_ca_pem(self, pem: impl Into<Vec<u8>>) -> Self

Available on crate feature 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.

Source

pub fn tls_client_identity( self, cert_pem: impl Into<Vec<u8>>, key_pem: impl Into<Vec<u8>>, ) -> Self

Available on crate feature 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.

Source

pub fn tls_domain(self, domain: impl Into<String>) -> Self

Available on crate feature 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.

Source

pub async fn connect(self) -> Result<StreamClient, StreamError>

Connect the transport and return a ready StreamClient.

Trait Implementations§

Source§

impl Clone for StreamClientBuilder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StreamClientBuilder

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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 = !

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

fn try_from(value: U) -> Result<T, !>

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more