Skip to content

Commit

Permalink
proto-build: bump neoeinstein-tonic to v0.3.0 (#430)
Browse files Browse the repository at this point in the history
Updates to the latest version of `protoc-gen-tonic`.
  • Loading branch information
tony-iqlusion authored Oct 2, 2023
1 parent ab82f6c commit c1b4025
Show file tree
Hide file tree
Showing 26 changed files with 5,252 additions and 1,538 deletions.
74 changes: 63 additions & 11 deletions cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.app.v1alpha1.tonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod query_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 @@ -73,12 +73,29 @@ pub mod query_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
}
/** Config returns the current app config.
*/
pub async fn config(
&mut self,
request: impl tonic::IntoRequest<super::QueryConfigRequest>,
) -> Result<tonic::Response<super::QueryConfigResponse>, tonic::Status> {
) -> std::result::Result<tonic::Response<super::QueryConfigResponse>, tonic::Status>
{
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
Expand All @@ -87,7 +104,10 @@ pub mod query_client {
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/cosmos.app.v1alpha1.Query/Config");
self.inner.unary(request.into_request(), path, codec).await
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("cosmos.app.v1alpha1.Query", "Config"));
self.inner.unary(req, path, codec).await
}
}
}
Expand All @@ -105,7 +125,7 @@ pub mod query_server {
async fn config(
&self,
request: tonic::Request<super::QueryConfigRequest>,
) -> Result<tonic::Response<super::QueryConfigResponse>, tonic::Status>;
) -> std::result::Result<tonic::Response<super::QueryConfigResponse>, tonic::Status>;
}
/** Query is the app module query service.
*/
Expand All @@ -114,6 +134,8 @@ pub mod query_server {
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: Query> QueryServer<T> {
Expand All @@ -126,6 +148,8 @@ pub mod query_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>(inner: T, interceptor: F) -> InterceptedService<Self, F>
Expand All @@ -146,6 +170,22 @@ pub mod query_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 QueryServer<T>
where
Expand All @@ -156,7 +196,10 @@ pub mod query_server {
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>> {
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 {
Expand All @@ -172,22 +215,29 @@ pub mod query_server {
&mut self,
request: tonic::Request<super::QueryConfigRequest>,
) -> Self::Future {
let inner = self.0.clone();
let inner = Arc::clone(&self.0);
let fut = async move { (*inner).config(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 = ConfigSvc(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 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)
};
Expand All @@ -211,12 +261,14 @@ pub mod query_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: Query> 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
Loading

0 comments on commit c1b4025

Please sign in to comment.