Skip to main content

Crate tonin_client

Crate tonin_client 

Source
Expand description

Tiny peer-service client primitives. No server-framework deps.

§When to use

Service B calls Service A — pull this in, not tonin-core, which drags the tonic server stack, OTLP telemetry SDK, MCP sidecar runtime, JWT validation and JWKS fetching along with it. This crate holds only the contract pieces a caller actually needs: auth context, retry/breaker config, and W3C trace propagation.

§Example

Propagate an inbound AuthCtx + traceparent onto an outbound tonic request:

use tonin_client::{AuthCtx, propagate};
use tonic::Request;

fn forward(inbound: &Request<()>) -> Request<()> {
    let caller = AuthCtx::from(inbound);
    let mut outbound = Request::new(());
    caller.propagate(&mut outbound);
    propagate::inject_traceparent(
        &mut outbound,
        "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01",
    );
    outbound
}

§Modules

  • authAuthCtx, RawToken, PrincipalKind, AuthError.
  • retryRetryPolicy, Backoff, RetryableCodes.
  • breakerCircuitBreaker config with three-state presets.
  • propagate — W3C traceparent / tracestate injection.

§Sample app

https://github.com/Rushit/tonin/tree/main/examples/greeter — Service B in the demo depends on this crate to call Service A.

§Sibling crates

Re-exports§

pub use auth::AuthCtx;
pub use auth::AuthError;
pub use auth::PrincipalKind;
pub use auth::RawToken;

Modules§

auth
Auth types shared between server and client.
breaker
Circuit-breaker configuration for outbound calls.
propagate
Request-header helpers for outbound calls.
retry
Retry-policy configuration for outbound calls.