//! RPC helpers built on tonic.

tokio::task_local! {
    pub(crate) static RPC_REQUEST_ID_SCOPE: std::sync::Arc<String>;
}

#[cfg(feature = "discovery")]
pub mod balancer;
pub mod client;
pub mod config;
pub mod deadline;
#[cfg(feature = "discovery")]
pub mod discovery;
pub mod interceptor;
#[cfg(all(feature = "resil", feature = "cache-redis"))]
mod limiter;
#[cfg(feature = "resil")]
pub mod resilience;
#[cfg(feature = "resil")]
pub mod resilience_layer;
pub mod retry;
pub mod server;
pub mod streaming;

pub use client::{RpcClientBuilder, connect_channel, endpoint_from_config};
#[cfg(feature = "discovery")]
pub use client::{RpcConnectError, connect_discovered_channel, endpoint_from_rpc_endpoint};
#[cfg(all(feature = "resil", feature = "cache-redis"))]
pub use config::RpcRateLimiterConfig;
pub use config::{
    LoadBalancePolicy, RpcClientConfig, RpcDeadlineConfig, RpcDiscoveryConfig,
    RpcLoadBalanceConfig, RpcResilienceConfig, RpcRetryConfig, RpcServerConfig, RpcStreamingConfig,
};
#[cfg(feature = "observability")]
pub use interceptor::trace_context_interceptor;
pub use interceptor::{
    REQUEST_ID_METADATA, RpcRequestId, deadline_interceptor, request_id_interceptor,
    resilience_rejection_status, rpc_resilience_key, with_rpc_request_id,
};
#[cfg(feature = "resil")]
pub use resilience::{RpcResilienceLayer, status_counts_as_failure};
#[cfg(feature = "resil")]
pub use resilience_layer::{RpcUnaryResilienceLayer, RpcUnaryResilienceService};
#[cfg(feature = "resil")]
pub use server::RpcServerLayerStack;
pub use server::{TonicHealthService, TonicService, serve_health_with_shutdown};
