//! Typed gRPC client for the `{{ service_name }}` service.
//!
//! Generated by `tonin service new`. Hand-editing this file is fine —
//! `cargo build` regenerates the `proto::*` module from `../proto/*.proto`
//! but does NOT touch the items below it.
//!
//! ## Coalescing + cache
//!
//! The generated `{{ ServiceCamel }}CoalescingClient` wraps the raw tonic
//! client and provides:
//!
//! - **Request coalescing** — concurrent identical in-flight calls share
//!   one upstream RPC (default: {% if client.coalesce %}ON{% else %}OFF{% endif %}).
//! - **Per-method TTL cache** — opt-in per method (see below).
//!
//! ### Wrapping the tonic client
//!
//! ```ignore
//! use {{ service_name_snake }}_client::{
//!     {{ ServiceCamel }}Client, CoalescingClient,
//! };
//! use tonin_client::cache::CacheConfig;
//! use std::time::Duration;
//!
//! let inner = {{ ServiceCamel }}Client::connect("http://{{ service_name }}:50051").await?;
//!
//! // Default: coalescing on, no TTL cache.
//! let client = CoalescingClient::new(inner);
//!
//! // Or build with per-method TTL cache:
//! let client = CoalescingClient::builder(inner)
{%- for cache in client.caches %}
//!     .cache("{{ cache.0 }}", CacheConfig::new(
//!         Duration::from_millis({{ cache.1.ttl_ms }}),
//!         {{ cache.1.capacity }},
//!     ))
{%- endfor %}
//!     .build();
//!
//! // Call a method through the coalescing client:
//! let req_bytes = prost::Message::encode_to_vec(&my_request);
//! let resp = client
//!     .call::<HelloReply, _, _>(
//!         "{{ service_name_snake }}.v1.{{ ServiceCamel }}",
//!         "SayHello",
//!         req_bytes,
//!         move || async move { inner.say_hello(tonic::Request::new(my_request)).await },
//!     )
//!     .await?;
//! ```
//!
//! ## Raw tonic client
//!
//! For streaming calls or when coalescing is not needed, use the raw
//! tonic client via `client.inner`:
//!
//! ```ignore
//! let mut req = tonic::Request::new(HelloRequest { name: "world".into() });
//! AuthCtx::from_bearer(my_token).propagate(&mut req);
//! let resp = client.inner.say_hello(req).await?;
//! ```

#![doc = include_str!("../README.md")]

pub mod proto {
    tonic::include_proto!("{{ service_name_snake }}.v1");
}

// Convenience re-exports so callers can `use {{ service_name_snake }}_client::*`
// and pick up the common surface without digging through `proto::`.
//
// The Rust client lives at `proto::{{ service_proto_module }}_client::{{ ServiceCamel }}Client`.
// `{{ service_proto_module }}` is prost's snake-casing of the proto
// service name (`{{ ServiceCamel }}`), which differs from the package
// name's snake-casing when the service name contains digits — that's
// why we keep them as two separate template vars.
pub use proto::{{ service_proto_module }}_client::{{ ServiceCamel }}Client;
pub use proto::{HelloReply, HelloRequest};

// Shared client-side primitives from `tonin-client`. Re-exported at
// the top level so peers don't need to learn the two-crate split.
pub use tonin_client::auth::{AuthCtx, AuthError, PrincipalKind, RawToken};
pub use tonin_client::breaker::CircuitBreaker;
pub use tonin_client::cache::CacheConfig;
pub use tonin_client::client::{ClientConfig, CoalescingClient};
pub use tonin_client::retry::{Backoff, RetryPolicy, RetryableCodes};
pub use tonin_client::{breaker, cache, client, coalesce, propagate, retry};
