Skip to content

Commit 66e049a

Browse files
authored
fix(tonic): align compression API with latest tonic (#253)
1 parent 8c5a805 commit 66e049a

File tree

5 files changed

+22
-31
lines changed

5 files changed

+22
-31
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## tonic [0.5.2] - 2025-12-03
10+
11+
### Changed
12+
- Aligned compression API with latest tonic.
13+
914
## madsim [0.2.34] - 2025-10-10
1015

1116
### Changed

madsim-tonic-build/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "madsim-tonic-build"
3-
version = "0.5.1+0.12.3"
3+
version = "0.5.2+0.12.3"
44
edition = "2021"
55
authors = [
66
"Lucio Franco <luciofranco14@gmail.com>",
@@ -24,7 +24,6 @@ syn = "2"
2424
tonic-build = "0.12.3"
2525

2626
[features]
27-
compression = []
2827
default = ["transport", "prost"]
2928
prost = ["prost-build"]
3029
transport = []

madsim-tonic-build/src/client.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ pub fn generate<T: Service>(
4040
unused_variables,
4141
dead_code,
4242
missing_docs,
43-
// will trigger if compression is disabled
44-
clippy::let_unit_value,
4543
)]
4644
use tonic::codegen::*;
4745

madsim-tonic-build/src/server.rs

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,20 @@ pub fn generate<T: Service>(
3939
// let mod_attributes = attributes.for_mod(package);
4040
// let struct_attributes = attributes.for_struct(&path);
4141

42-
let compression_enabled = cfg!(feature = "compression");
43-
44-
// let compression_config_ty = if compression_enabled {
45-
// quote! { EnabledCompressionEncodings }
46-
// } else {
47-
// quote! { () }
48-
// };
49-
50-
let configure_compression_methods = if compression_enabled {
51-
quote! {
52-
/// Enable decompressing requests with the given encoding.
53-
#[must_use]
54-
pub fn accept_compressed(self, _encoding: CompressionEncoding) -> Self {
55-
// self.accept_compression_encodings.enable(encoding);
56-
self
57-
}
58-
/// Compress responses with the given encoding, if the client supports it.
59-
#[must_use]
60-
pub fn send_compressed(self, _encoding: CompressionEncoding) -> Self {
61-
// self.send_compression_encodings.enable(encoding);
62-
self
63-
}
42+
let configure_compression_methods = quote! {
43+
/// Enable decompressing requests with the given encoding.
44+
#[must_use]
45+
pub fn accept_compressed(self, _encoding: CompressionEncoding) -> Self {
46+
// self.accept_compression_encodings.enable(encoding);
47+
self
48+
}
49+
50+
/// Compress responses with the given encoding, if the client supports it.
51+
#[must_use]
52+
pub fn send_compressed(self, _encoding: CompressionEncoding) -> Self {
53+
// self.send_compression_encodings.enable(encoding);
54+
self
6455
}
65-
} else {
66-
quote! {}
6756
};
6857

6958
let configure_max_message_size_methods = quote! {
@@ -92,8 +81,6 @@ pub fn generate<T: Service>(
9281
dead_code,
9382
missing_docs,
9483
unused_mut,
95-
// will trigger if compression is disabled
96-
clippy::let_unit_value,
9784
)]
9885
use tonic::codegen::{http::uri::PathAndQuery, futures::{stream::{self, Stream, StreamExt}, future::FutureExt}, *};
9986

madsim-tonic/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "madsim-tonic"
3-
version = "0.5.1+0.12.0"
3+
version = "0.5.2+0.12.0"
44
edition = "2021"
55
authors = ["Runji Wang <wangrunji0408@163.com>"]
66
description = "The `tonic` simulator on madsim."
@@ -13,6 +13,8 @@ license = "Apache-2.0"
1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[features]
16+
gzip = ["tonic/gzip"]
17+
zstd = ["tonic/zstd"]
1618
tls = ["tonic/tls"]
1719

1820
[target.'cfg(not(madsim))'.dependencies]

0 commit comments

Comments
 (0)