#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetDestination {
#[prost(string, tag="1")]
pub scheme: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub path: ::prost::alloc::string::String,
#[prost(string, tag="3")]
pub context_token: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Update {
#[prost(oneof="update::Update", tags="1, 2, 3")]
pub update: ::core::option::Option<update::Update>,
}
pub mod update {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Update {
#[prost(message, tag="1")]
Add(super::WeightedAddrSet),
#[prost(message, tag="2")]
Remove(super::AddrSet),
#[prost(message, tag="3")]
NoEndpoints(super::NoEndpoints),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AddrSet {
#[prost(message, repeated, tag="1")]
pub addrs: ::prost::alloc::vec::Vec<super::net::TcpAddress>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WeightedAddrSet {
#[prost(message, repeated, tag="1")]
pub addrs: ::prost::alloc::vec::Vec<WeightedAddr>,
#[prost(map="string, string", tag="2")]
pub metric_labels: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WeightedAddr {
#[prost(message, optional, tag="1")]
pub addr: ::core::option::Option<super::net::TcpAddress>,
#[prost(uint32, tag="3")]
pub weight: u32,
#[prost(map="string, string", tag="4")]
pub metric_labels: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
#[prost(message, optional, tag="5")]
pub tls_identity: ::core::option::Option<TlsIdentity>,
#[prost(message, optional, tag="6")]
pub protocol_hint: ::core::option::Option<ProtocolHint>,
#[prost(message, optional, tag="7")]
pub authority_override: ::core::option::Option<AuthorityOverride>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TlsIdentity {
#[prost(oneof="tls_identity::Strategy", tags="1")]
pub strategy: ::core::option::Option<tls_identity::Strategy>,
}
pub mod tls_identity {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DnsLikeIdentity {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Strategy {
#[prost(message, tag="1")]
DnsLikeIdentity(DnsLikeIdentity),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AuthorityOverride {
#[prost(string, tag="1")]
pub authority_override: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NoEndpoints {
#[prost(bool, tag="1")]
pub exists: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProtocolHint {
#[prost(message, optional, tag="2")]
pub opaque_transport: ::core::option::Option<protocol_hint::OpaqueTransport>,
#[prost(oneof="protocol_hint::Protocol", tags="1")]
pub protocol: ::core::option::Option<protocol_hint::Protocol>,
}
pub mod protocol_hint {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct H2 {
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OpaqueTransport {
#[prost(uint32, tag="1")]
pub inbound_port: u32,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Protocol {
#[prost(message, tag="1")]
H2(H2),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DestinationProfile {
#[prost(string, tag="5")]
pub fully_qualified_name: ::prost::alloc::string::String,
#[prost(bool, tag="4")]
pub opaque_protocol: bool,
#[prost(message, repeated, tag="1")]
pub routes: ::prost::alloc::vec::Vec<Route>,
#[prost(message, optional, tag="2")]
pub retry_budget: ::core::option::Option<RetryBudget>,
#[prost(message, repeated, tag="3")]
pub dst_overrides: ::prost::alloc::vec::Vec<WeightedDst>,
#[prost(message, optional, tag="6")]
pub endpoint: ::core::option::Option<WeightedAddr>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Route {
#[prost(message, optional, tag="1")]
pub condition: ::core::option::Option<RequestMatch>,
#[prost(message, repeated, tag="2")]
pub response_classes: ::prost::alloc::vec::Vec<ResponseClass>,
#[prost(map="string, string", tag="3")]
pub metrics_labels: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
#[prost(bool, tag="4")]
pub is_retryable: bool,
#[prost(message, optional, tag="5")]
pub timeout: ::core::option::Option<::prost_types::Duration>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RetryBudget {
#[prost(float, tag="1")]
pub retry_ratio: f32,
#[prost(uint32, tag="2")]
pub min_retries_per_second: u32,
#[prost(message, optional, tag="3")]
pub ttl: ::core::option::Option<::prost_types::Duration>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseClass {
#[prost(message, optional, tag="1")]
pub condition: ::core::option::Option<ResponseMatch>,
#[prost(bool, tag="2")]
pub is_failure: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestMatch {
#[prost(oneof="request_match::Match", tags="1, 2, 3, 4, 5")]
pub r#match: ::core::option::Option<request_match::Match>,
}
pub mod request_match {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Seq {
#[prost(message, repeated, tag="1")]
pub matches: ::prost::alloc::vec::Vec<super::RequestMatch>,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Match {
#[prost(message, tag="1")]
All(Seq),
#[prost(message, tag="2")]
Any(Seq),
#[prost(message, tag="3")]
Not(::prost::alloc::boxed::Box<super::RequestMatch>),
#[prost(message, tag="4")]
Path(super::PathMatch),
#[prost(message, tag="5")]
Method(super::super::http_types::HttpMethod),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PathMatch {
#[prost(string, tag="1")]
pub regex: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseMatch {
#[prost(oneof="response_match::Match", tags="1, 2, 3, 4")]
pub r#match: ::core::option::Option<response_match::Match>,
}
pub mod response_match {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Seq {
#[prost(message, repeated, tag="1")]
pub matches: ::prost::alloc::vec::Vec<super::ResponseMatch>,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Match {
#[prost(message, tag="1")]
All(Seq),
#[prost(message, tag="2")]
Any(Seq),
#[prost(message, tag="3")]
Not(::prost::alloc::boxed::Box<super::ResponseMatch>),
#[prost(message, tag="4")]
Status(super::HttpStatusRange),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HttpStatusRange {
#[prost(uint32, tag="1")]
pub min: u32,
#[prost(uint32, tag="2")]
pub max: u32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WeightedDst {
#[prost(string, tag="1")]
pub authority: ::prost::alloc::string::String,
#[prost(uint32, tag="2")]
pub weight: u32,
}
pub mod destination_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 DestinationClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> DestinationClient<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,
) -> DestinationClient<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,
{
DestinationClient::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
}
pub async fn get(
&mut self,
request: impl tonic::IntoRequest<super::GetDestination>,
) -> Result<
tonic::Response<tonic::codec::Streaming<super::Update>>,
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.destination.Destination/Get",
);
self.inner.server_streaming(request.into_request(), path, codec).await
}
pub async fn get_profile(
&mut self,
request: impl tonic::IntoRequest<super::GetDestination>,
) -> Result<
tonic::Response<tonic::codec::Streaming<super::DestinationProfile>>,
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.destination.Destination/GetProfile",
);
self.inner.server_streaming(request.into_request(), path, codec).await
}
}
}
pub mod destination_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait Destination: Send + Sync + 'static {
type GetStream: futures_core::Stream<Item = Result<super::Update, tonic::Status>>
+ Send
+ 'static;
async fn get(
&self,
request: tonic::Request<super::GetDestination>,
) -> Result<tonic::Response<Self::GetStream>, tonic::Status>;
type GetProfileStream: futures_core::Stream<
Item = Result<super::DestinationProfile, tonic::Status>,
>
+ Send
+ 'static;
async fn get_profile(
&self,
request: tonic::Request<super::GetDestination>,
) -> Result<tonic::Response<Self::GetProfileStream>, tonic::Status>;
}
#[derive(Debug)]
pub struct DestinationServer<T: Destination> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
}
struct _Inner<T>(Arc<T>);
impl<T: Destination> DestinationServer<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(),
}
}
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
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for DestinationServer<T>
where
T: Destination,
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<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.destination.Destination/Get" => {
#[allow(non_camel_case_types)]
struct GetSvc<T: Destination>(pub Arc<T>);
impl<
T: Destination,
> tonic::server::ServerStreamingService<super::GetDestination>
for GetSvc<T> {
type Response = super::Update;
type ResponseStream = T::GetStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetDestination>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).get(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
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,
);
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.linkerd.proxy.destination.Destination/GetProfile" => {
#[allow(non_camel_case_types)]
struct GetProfileSvc<T: Destination>(pub Arc<T>);
impl<
T: Destination,
> tonic::server::ServerStreamingService<super::GetDestination>
for GetProfileSvc<T> {
type Response = super::DestinationProfile;
type ResponseStream = T::GetProfileStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetDestination>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).get_profile(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = GetProfileSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
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: Destination> Clone for DestinationServer<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,
}
}
}
impl<T: Destination> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
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: Destination> tonic::server::NamedService for DestinationServer<T> {
const NAME: &'static str = "io.linkerd.proxy.destination.Destination";
}
}