#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrafficSpec {
#[prost(string, tag = "1")]
pub source_workload: ::prost::alloc::string::String,
#[prost(oneof = "traffic_spec::Target", tags = "2, 3")]
pub target: ::core::option::Option<traffic_spec::Target>,
}
pub mod traffic_spec {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Target {
#[prost(message, tag = "2")]
Addr(super::super::net::TcpAddress),
#[prost(string, tag = "3")]
Authority(::prost::alloc::string::String),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OutboundPolicy {
#[prost(message, optional, tag = "1")]
pub protocol: ::core::option::Option<ProxyProtocol>,
#[prost(message, optional, tag = "2")]
pub metadata: ::core::option::Option<super::meta::Metadata>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProxyProtocol {
#[prost(oneof = "proxy_protocol::Kind", tags = "1, 2, 3, 4, 5")]
pub kind: ::core::option::Option<proxy_protocol::Kind>,
}
pub mod proxy_protocol {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Detect {
#[prost(message, optional, tag = "1")]
pub timeout: ::core::option::Option<::prost_types::Duration>,
#[prost(message, optional, tag = "2")]
pub opaque: ::core::option::Option<Opaque>,
#[prost(message, optional, tag = "3")]
pub http1: ::core::option::Option<Http1>,
#[prost(message, optional, tag = "4")]
pub http2: ::core::option::Option<Http2>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Opaque {
#[prost(message, repeated, tag = "1")]
pub routes: ::prost::alloc::vec::Vec<super::OpaqueRoute>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Http1 {
#[prost(message, repeated, tag = "1")]
pub routes: ::prost::alloc::vec::Vec<super::HttpRoute>,
#[prost(message, optional, tag = "2")]
pub failure_accrual: ::core::option::Option<super::FailureAccrual>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Http2 {
#[prost(message, repeated, tag = "1")]
pub routes: ::prost::alloc::vec::Vec<super::HttpRoute>,
#[prost(message, optional, tag = "2")]
pub failure_accrual: ::core::option::Option<super::FailureAccrual>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Grpc {
#[prost(message, repeated, tag = "1")]
pub routes: ::prost::alloc::vec::Vec<super::GrpcRoute>,
#[prost(message, optional, tag = "2")]
pub failure_accrual: ::core::option::Option<super::FailureAccrual>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
Detect(Detect),
#[prost(message, tag = "2")]
Opaque(Opaque),
#[prost(message, tag = "3")]
Http1(Http1),
#[prost(message, tag = "4")]
Http2(Http2),
#[prost(message, tag = "5")]
Grpc(Grpc),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HttpRoute {
#[prost(message, optional, tag = "1")]
pub metadata: ::core::option::Option<super::meta::Metadata>,
#[prost(message, repeated, tag = "2")]
pub hosts: ::prost::alloc::vec::Vec<super::http_route::HostMatch>,
#[prost(message, repeated, tag = "3")]
pub rules: ::prost::alloc::vec::Vec<http_route::Rule>,
}
pub mod http_route {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Rule {
#[prost(message, repeated, tag = "1")]
pub matches: ::prost::alloc::vec::Vec<super::super::http_route::HttpRouteMatch>,
#[prost(message, repeated, tag = "2")]
pub filters: ::prost::alloc::vec::Vec<Filter>,
#[prost(message, optional, tag = "3")]
pub backends: ::core::option::Option<Distribution>,
#[prost(message, optional, tag = "4")]
pub request_timeout: ::core::option::Option<::prost_types::Duration>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Filter {
#[prost(oneof = "filter::Kind", tags = "1, 2, 3, 4")]
pub kind: ::core::option::Option<filter::Kind>,
}
pub mod filter {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
FailureInjector(super::super::super::http_route::HttpFailureInjector),
#[prost(message, tag = "2")]
RequestHeaderModifier(
super::super::super::http_route::RequestHeaderModifier,
),
#[prost(message, tag = "3")]
Redirect(super::super::super::http_route::RequestRedirect),
#[prost(message, tag = "4")]
ResponseHeaderModifier(
super::super::super::http_route::ResponseHeaderModifier,
),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Distribution {
#[prost(oneof = "distribution::Kind", tags = "1, 2, 3")]
pub kind: ::core::option::Option<distribution::Kind>,
}
pub mod distribution {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Empty {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FirstAvailable {
#[prost(message, repeated, tag = "1")]
pub backends: ::prost::alloc::vec::Vec<super::RouteBackend>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RandomAvailable {
#[prost(message, repeated, tag = "1")]
pub backends: ::prost::alloc::vec::Vec<super::WeightedRouteBackend>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
Empty(Empty),
#[prost(message, tag = "2")]
FirstAvailable(FirstAvailable),
#[prost(message, tag = "3")]
RandomAvailable(RandomAvailable),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RouteBackend {
#[prost(message, optional, tag = "1")]
pub backend: ::core::option::Option<super::Backend>,
#[prost(message, repeated, tag = "3")]
pub filters: ::prost::alloc::vec::Vec<Filter>,
#[prost(message, optional, tag = "4")]
pub request_timeout: ::core::option::Option<::prost_types::Duration>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WeightedRouteBackend {
#[prost(message, optional, tag = "1")]
pub backend: ::core::option::Option<RouteBackend>,
#[prost(uint32, tag = "2")]
pub weight: u32,
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GrpcRoute {
#[prost(message, optional, tag = "1")]
pub metadata: ::core::option::Option<super::meta::Metadata>,
#[prost(message, repeated, tag = "2")]
pub hosts: ::prost::alloc::vec::Vec<super::http_route::HostMatch>,
#[prost(message, repeated, tag = "3")]
pub rules: ::prost::alloc::vec::Vec<grpc_route::Rule>,
}
pub mod grpc_route {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Rule {
#[prost(message, repeated, tag = "1")]
pub matches: ::prost::alloc::vec::Vec<super::super::grpc_route::GrpcRouteMatch>,
#[prost(message, repeated, tag = "2")]
pub filters: ::prost::alloc::vec::Vec<Filter>,
#[prost(message, optional, tag = "3")]
pub backends: ::core::option::Option<Distribution>,
#[prost(message, optional, tag = "4")]
pub request_timeout: ::core::option::Option<::prost_types::Duration>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Filter {
#[prost(oneof = "filter::Kind", tags = "1, 2")]
pub kind: ::core::option::Option<filter::Kind>,
}
pub mod filter {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
FailureInjector(super::super::super::grpc_route::GrpcFailureInjector),
#[prost(message, tag = "2")]
RequestHeaderModifier(
super::super::super::http_route::RequestHeaderModifier,
),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Distribution {
#[prost(oneof = "distribution::Kind", tags = "1, 2, 3")]
pub kind: ::core::option::Option<distribution::Kind>,
}
pub mod distribution {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Empty {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FirstAvailable {
#[prost(message, repeated, tag = "1")]
pub backends: ::prost::alloc::vec::Vec<super::RouteBackend>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RandomAvailable {
#[prost(message, repeated, tag = "1")]
pub backends: ::prost::alloc::vec::Vec<super::WeightedRouteBackend>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
Empty(Empty),
#[prost(message, tag = "2")]
FirstAvailable(FirstAvailable),
#[prost(message, tag = "3")]
RandomAvailable(RandomAvailable),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RouteBackend {
#[prost(message, optional, tag = "1")]
pub backend: ::core::option::Option<super::Backend>,
#[prost(message, repeated, tag = "3")]
pub filters: ::prost::alloc::vec::Vec<Filter>,
#[prost(message, optional, tag = "4")]
pub request_timeout: ::core::option::Option<::prost_types::Duration>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WeightedRouteBackend {
#[prost(message, optional, tag = "1")]
pub backend: ::core::option::Option<RouteBackend>,
#[prost(uint32, tag = "2")]
pub weight: u32,
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OpaqueRoute {
#[prost(message, optional, tag = "1")]
pub metadata: ::core::option::Option<super::meta::Metadata>,
#[prost(message, repeated, tag = "3")]
pub rules: ::prost::alloc::vec::Vec<opaque_route::Rule>,
}
pub mod opaque_route {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Rule {
#[prost(message, optional, tag = "1")]
pub backends: ::core::option::Option<Distribution>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Distribution {
#[prost(oneof = "distribution::Kind", tags = "1, 2, 3")]
pub kind: ::core::option::Option<distribution::Kind>,
}
pub mod distribution {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Empty {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FirstAvailable {
#[prost(message, repeated, tag = "1")]
pub backends: ::prost::alloc::vec::Vec<super::RouteBackend>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RandomAvailable {
#[prost(message, repeated, tag = "1")]
pub backends: ::prost::alloc::vec::Vec<super::WeightedRouteBackend>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
Empty(Empty),
#[prost(message, tag = "2")]
FirstAvailable(FirstAvailable),
#[prost(message, tag = "3")]
RandomAvailable(RandomAvailable),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RouteBackend {
#[prost(message, optional, tag = "1")]
pub backend: ::core::option::Option<super::Backend>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WeightedRouteBackend {
#[prost(message, optional, tag = "1")]
pub backend: ::core::option::Option<RouteBackend>,
#[prost(uint32, tag = "2")]
pub weight: u32,
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Backend {
#[prost(message, optional, tag = "1")]
pub metadata: ::core::option::Option<super::meta::Metadata>,
#[prost(message, optional, tag = "4")]
pub queue: ::core::option::Option<Queue>,
#[prost(oneof = "backend::Kind", tags = "2, 3")]
pub kind: ::core::option::Option<backend::Kind>,
}
pub mod backend {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EndpointDiscovery {
#[prost(oneof = "endpoint_discovery::Kind", tags = "1")]
pub kind: ::core::option::Option<endpoint_discovery::Kind>,
}
pub mod endpoint_discovery {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DestinationGet {
#[prost(string, tag = "1")]
pub path: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
Dst(DestinationGet),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BalanceP2c {
#[prost(message, optional, tag = "1")]
pub discovery: ::core::option::Option<EndpointDiscovery>,
#[prost(oneof = "balance_p2c::Load", tags = "2")]
pub load: ::core::option::Option<balance_p2c::Load>,
}
pub mod balance_p2c {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PeakEwma {
#[prost(message, optional, tag = "1")]
pub default_rtt: ::core::option::Option<::prost_types::Duration>,
#[prost(message, optional, tag = "2")]
pub decay: ::core::option::Option<::prost_types::Duration>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Load {
#[prost(message, tag = "2")]
PeakEwma(PeakEwma),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(message, tag = "2")]
Forward(super::super::destination::WeightedAddr),
#[prost(message, tag = "3")]
Balancer(BalanceP2c),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Queue {
#[prost(uint32, tag = "1")]
pub capacity: u32,
#[prost(message, optional, tag = "2")]
pub failfast_timeout: ::core::option::Option<::prost_types::Duration>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FailureAccrual {
#[prost(oneof = "failure_accrual::Kind", tags = "1")]
pub kind: ::core::option::Option<failure_accrual::Kind>,
}
pub mod failure_accrual {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConsecutiveFailures {
#[prost(uint32, tag = "1")]
pub max_failures: u32,
#[prost(message, optional, tag = "2")]
pub backoff: ::core::option::Option<super::ExponentialBackoff>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(message, tag = "1")]
ConsecutiveFailures(ConsecutiveFailures),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExponentialBackoff {
#[prost(message, optional, tag = "1")]
pub min_backoff: ::core::option::Option<::prost_types::Duration>,
#[prost(message, optional, tag = "2")]
pub max_backoff: ::core::option::Option<::prost_types::Duration>,
#[prost(float, tag = "3")]
pub jitter_ratio: f32,
}
pub mod outbound_policies_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct OutboundPoliciesClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> OutboundPoliciesClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> OutboundPoliciesClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
OutboundPoliciesClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn get(
&mut self,
request: impl tonic::IntoRequest<super::TrafficSpec>,
) -> std::result::Result<tonic::Response<super::OutboundPolicy>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.linkerd.proxy.outbound.OutboundPolicies/Get",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("io.linkerd.proxy.outbound.OutboundPolicies", "Get"),
);
self.inner.unary(req, path, codec).await
}
pub async fn watch(
&mut self,
request: impl tonic::IntoRequest<super::TrafficSpec>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::OutboundPolicy>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.linkerd.proxy.outbound.OutboundPolicies/Watch",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"io.linkerd.proxy.outbound.OutboundPolicies",
"Watch",
),
);
self.inner.server_streaming(req, path, codec).await
}
}
}
pub mod outbound_policies_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait OutboundPolicies: Send + Sync + 'static {
async fn get(
&self,
request: tonic::Request<super::TrafficSpec>,
) -> std::result::Result<tonic::Response<super::OutboundPolicy>, tonic::Status>;
type WatchStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::OutboundPolicy, tonic::Status>,
>
+ Send
+ 'static;
async fn watch(
&self,
request: tonic::Request<super::TrafficSpec>,
) -> std::result::Result<tonic::Response<Self::WatchStream>, tonic::Status>;
}
#[derive(Debug)]
pub struct OutboundPoliciesServer<T: OutboundPolicies> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: OutboundPolicies> OutboundPoliciesServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for OutboundPoliciesServer<T>
where
T: OutboundPolicies,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/io.linkerd.proxy.outbound.OutboundPolicies/Get" => {
#[allow(non_camel_case_types)]
struct GetSvc<T: OutboundPolicies>(pub Arc<T>);
impl<
T: OutboundPolicies,
> tonic::server::UnaryService<super::TrafficSpec> for GetSvc<T> {
type Response = super::OutboundPolicy;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::TrafficSpec>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as OutboundPolicies>::get(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = GetSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.linkerd.proxy.outbound.OutboundPolicies/Watch" => {
#[allow(non_camel_case_types)]
struct WatchSvc<T: OutboundPolicies>(pub Arc<T>);
impl<
T: OutboundPolicies,
> tonic::server::ServerStreamingService<super::TrafficSpec>
for WatchSvc<T> {
type Response = super::OutboundPolicy;
type ResponseStream = T::WatchStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::TrafficSpec>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as OutboundPolicies>::watch(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = WatchSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: OutboundPolicies> Clone for OutboundPoliciesServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
impl<T: OutboundPolicies> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: OutboundPolicies> tonic::server::NamedService for OutboundPoliciesServer<T> {
const NAME: &'static str = "io.linkerd.proxy.outbound.OutboundPolicies";
}
}