tonin-client
Client-side primitives for code that calls a tonin service from another service.
Part of the tonin framework.
When to use this crate
You are writing service B, and B calls service A (which is built on tonin). You want:
- the same
AuthCtxshape A produces, so you can forward the caller's identity to A - W3C trace-context propagation, so A's spans join your trace
- retry / circuit-breaker config types, so the knobs match what A's generated client SDK accepts
Pull in tonin-client, not tonin-core. The latter drags in the tonic server stack, the OTLP telemetry SDK, the MCP sidecar runtime, JWKS fetching, JWT validation, etc. — none of which a pure caller needs.
The dep tree here is intentionally tiny: tonic, http, serde, serde_json, thiserror, tracing. That's it.
Quick example
use ;
use Request;
// In a handler on service B, you already have an AuthCtx (the inbound
// auth layer put it in the request extensions on the way in).
async
Modules
auth—AuthCtx,RawToken,PrincipalKind,AuthError. The auth-context shape produced server-side bytonin-core::authand propagated outbound viaAuthCtx::propagate.retry—RetryPolicy,Backoff,RetryableCodes. Config for the outbound retry layer. Default is no retries; opt in explicitly withRetryPolicy::exponential(n)or::fixed(n, delay).breaker—CircuitBreakerconfig. Standard three-state breaker (Closed / Open / HalfOpen). Presets:default(),aggressive(),conservative().propagate—inject_traceparent/inject_tracestatefor W3C trace-context forwarding on outboundtonic::Requests.
What is NOT in this crate
By design:
- JWT validation, JWKS fetching, the
TokenVerifiertrait,AuthLayer(server-side — intonin-core) - The actual retry / circuit-breaker tower layers (server-side — in
tonin-core) - Anything that opens a TCP listener or needs
tonic-build - OpenTelemetry SDK / OTLP exporter (server-side — in
tonin-telemetry)
Licensed under the Apache License, Version 2.0.