Skip to main content

Module client

Module client 

Source
Expand description

Thunder RPC client — multiplexed, config-driven (SPEC-003, CLT-xxx).

One Client owns one TCP connection and multiplexes concurrent calls over it via a background reader task (CLT-001/010). Behavior is driven entirely by a Config (SPEC-002): handshake style, push policy, frame cap, in-flight bound, and error-string convention.

The application supplies that config — Thunder has no product registry to look one up in. Start from Config::standard and set your identity; override a dimension only where you actually diverge.

use thunder::{Client, ClientConfig, Config, Value};

let app = Config::standard().scheme("myapp").port(9000);
let config = ClientConfig::new().api_key("secret").client_name("demo");
let client = Client::connect_with("myapp://localhost", app, config).await?;
let pong = client.call("PING", vec![]).await?;
assert_eq!(pong.as_str(), Some("PONG"));
client.close().await;

The semantics here are the family’s “uniform floor” (PRD NFR-07): the same contract ships in TypeScript, Python, and C#. Error classes on ClientError are stable public API (CLT-052) — branch on the class and code, never on message text.

Re-exports§

pub use crate::wire::Config;
pub use crate::wire::Value;

Structs§

Client
A multiplexed, config-driven Thunder RPC client (SPEC-003).
ClientConfig
Client configuration: connect timeout default 10 s (CLT-001), per-call timeout default 30 s (CLT-020), optional credentials and client name for the handshake (CLT-002).
Endpoint
A resolved RPC endpoint: host plus concrete port.
HandshakeInfo
What the handshake learned about this connection (CLT-002).
Pool
A bounded pool of Clients over one endpoint (CLT-080).
PooledConn
RAII guard from Pool::acquire. Derefs to the Client, and returns the connection to the pool on drop so the next checkout reuses it — unless the connection was poisoned, in which case it is dropped and the next checkout connects fresh (CLT-014/030).

Enums§

ClientError
The stable error classes of the client contract (CLT-050).
Credentials
Credentials for the configured handshake (CLT-002). Auth state is per-connection and sticky — there are no per-call credentials (CLT-003).

Functions§

parse_endpoint
Parse an endpoint string against the application’s Config (CLT-070).