Skip to content

Commit

Permalink
automatic updates from build
Browse files Browse the repository at this point in the history
These must be some tonic automatic updates with
the new dep.

Signed-off-by: astoycos <[email protected]>
  • Loading branch information
astoycos authored and shaneutt committed Sep 1, 2023
1 parent e41e047 commit 795f92e
Showing 1 changed file with 84 additions and 15 deletions.
99 changes: 84 additions & 15 deletions dataplane/api-server/src/backends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub mod backends_client {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: std::convert::TryInto<tonic::transport::Endpoint>,
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Expand Down Expand Up @@ -111,10 +111,29 @@ pub mod backends_client {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[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_interface_index(
&mut self,
request: impl tonic::IntoRequest<super::PodIp>,
) -> Result<tonic::Response<super::InterfaceIndexConfirmation>, tonic::Status> {
) -> std::result::Result<
tonic::Response<super::InterfaceIndexConfirmation>,
tonic::Status,
> {
self.inner
.ready()
.await
Expand All @@ -128,12 +147,15 @@ pub mod backends_client {
let path = http::uri::PathAndQuery::from_static(
"/backends.backends/GetInterfaceIndex",
);
self.inner.unary(request.into_request(), path, codec).await
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("backends.backends", "GetInterfaceIndex"));
self.inner.unary(req, path, codec).await
}
pub async fn update(
&mut self,
request: impl tonic::IntoRequest<super::Targets>,
) -> Result<tonic::Response<super::Confirmation>, tonic::Status> {
) -> std::result::Result<tonic::Response<super::Confirmation>, tonic::Status> {
self.inner
.ready()
.await
Expand All @@ -145,12 +167,14 @@ pub mod backends_client {
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/backends.backends/Update");
self.inner.unary(request.into_request(), path, codec).await
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("backends.backends", "Update"));
self.inner.unary(req, path, codec).await
}
pub async fn delete(
&mut self,
request: impl tonic::IntoRequest<super::Vip>,
) -> Result<tonic::Response<super::Confirmation>, tonic::Status> {
) -> std::result::Result<tonic::Response<super::Confirmation>, tonic::Status> {
self.inner
.ready()
.await
Expand All @@ -162,7 +186,9 @@ pub mod backends_client {
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/backends.backends/Delete");
self.inner.unary(request.into_request(), path, codec).await
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("backends.backends", "Delete"));
self.inner.unary(req, path, codec).await
}
}
}
Expand All @@ -176,21 +202,26 @@ pub mod backends_server {
async fn get_interface_index(
&self,
request: tonic::Request<super::PodIp>,
) -> Result<tonic::Response<super::InterfaceIndexConfirmation>, tonic::Status>;
) -> std::result::Result<
tonic::Response<super::InterfaceIndexConfirmation>,
tonic::Status,
>;
async fn update(
&self,
request: tonic::Request<super::Targets>,
) -> Result<tonic::Response<super::Confirmation>, tonic::Status>;
) -> std::result::Result<tonic::Response<super::Confirmation>, tonic::Status>;
async fn delete(
&self,
request: tonic::Request<super::Vip>,
) -> Result<tonic::Response<super::Confirmation>, tonic::Status>;
) -> std::result::Result<tonic::Response<super::Confirmation>, tonic::Status>;
}
#[derive(Debug)]
pub struct BackendsServer<T: Backends> {
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: Backends> BackendsServer<T> {
Expand All @@ -203,6 +234,8 @@ pub mod backends_server {
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>(
Expand All @@ -226,6 +259,22 @@ pub mod backends_server {
self.send_compression_encodings.enable(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[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 BackendsServer<T>
where
Expand All @@ -239,7 +288,7 @@ pub mod backends_server {
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>> {
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
Expand All @@ -259,7 +308,7 @@ pub mod backends_server {
&mut self,
request: tonic::Request<super::PodIp>,
) -> Self::Future {
let inner = self.0.clone();
let inner = Arc::clone(&self.0);
let fut = async move {
(*inner).get_interface_index(request).await
};
Expand All @@ -268,6 +317,8 @@ pub mod backends_server {
}
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;
Expand All @@ -277,6 +328,10 @@ pub mod backends_server {
.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)
Expand All @@ -297,13 +352,15 @@ pub mod backends_server {
&mut self,
request: tonic::Request<super::Targets>,
) -> Self::Future {
let inner = self.0.clone();
let inner = Arc::clone(&self.0);
let fut = async move { (*inner).update(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;
Expand All @@ -313,6 +370,10 @@ pub mod backends_server {
.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)
Expand All @@ -333,13 +394,15 @@ pub mod backends_server {
&mut self,
request: tonic::Request<super::Vip>,
) -> Self::Future {
let inner = self.0.clone();
let inner = Arc::clone(&self.0);
let fut = async move { (*inner).delete(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;
Expand All @@ -349,6 +412,10 @@ pub mod backends_server {
.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)
Expand Down Expand Up @@ -377,12 +444,14 @@ pub mod backends_server {
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: Backends> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
Self(Arc::clone(&self.0))
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
Expand Down

0 comments on commit 795f92e

Please sign in to comment.