Skip to content

Commit 7d16f79

Browse files
authored
Merge branch 'master' into grpc-web-anything
2 parents a47bb6a + 1934825 commit 7d16f79

File tree

32 files changed

+312
-73
lines changed

32 files changed

+312
-73
lines changed

.github/workflows/CI.yml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ on:
77
pull_request: {}
88

99
jobs:
10+
11+
rustfmt:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: hecrj/setup-rust-action@v1
16+
with:
17+
components: rustfmt
18+
- run: cargo fmt --all --check
19+
1020
check:
1121
runs-on: ${{ matrix.os }}
1222
strategy:
@@ -21,7 +31,6 @@ jobs:
2131
- uses: hecrj/setup-rust-action@v1
2232
with:
2333
rust-version: ${{ matrix.rust }}
24-
components: rustfmt
2534
- uses: actions/checkout@v3
2635
- name: Install cargo-hack
2736
uses: baptiste0928/cargo-install@v1
@@ -31,13 +40,11 @@ jobs:
3140
uses: baptiste0928/cargo-install@v1
3241
with:
3342
crate: cargo-machete
34-
- name: Install Protoc
35-
uses: arduino/setup-protoc@v1
43+
- name: Install protoc
44+
uses: taiki-e/install-action@v2
3645
with:
37-
repo-token: ${{ secrets.GITHUB_TOKEN }}
46+
tool: protoc@3.20.3
3847
- uses: Swatinem/rust-cache@v2
39-
- name: Check fmt
40-
run: cargo fmt -- --check
4148
- name: Check unused dependencies
4249
run: cargo machete
4350
- name: Check features
@@ -54,10 +61,10 @@ jobs:
5461

5562
steps:
5663
- uses: actions/checkout@v3
57-
- name: Install Protoc
58-
uses: arduino/setup-protoc@v1
64+
- name: Install protoc
65+
uses: taiki-e/install-action@v2
5966
with:
60-
repo-token: ${{ secrets.GITHUB_TOKEN }}
67+
tool: protoc@3.20.3
6168
- uses: hecrj/setup-rust-action@v1
6269
with:
6370
rust-version: "1.60"
@@ -81,10 +88,10 @@ jobs:
8188
- uses: hecrj/setup-rust-action@v1
8289
with:
8390
rust-version: "1.60"
84-
- name: Install Protoc
85-
uses: arduino/setup-protoc@v1
91+
- name: Install protoc
92+
uses: taiki-e/install-action@v2
8693
with:
87-
repo-token: ${{ secrets.GITHUB_TOKEN }}
94+
tool: protoc@3.20.3
8895
- name: Check
8996
run: cargo check --all --all-targets --all-features
9097

@@ -104,11 +111,10 @@ jobs:
104111
- uses: hecrj/setup-rust-action@v1
105112
with:
106113
rust-version: ${{ matrix.rust }}
107-
components: rustfmt
108-
- name: Install Protoc
109-
uses: arduino/setup-protoc@v1
114+
- name: Install protoc
115+
uses: taiki-e/install-action@v2
110116
with:
111-
repo-token: ${{ secrets.GITHUB_TOKEN }}
117+
tool: protoc@3.20.3
112118
- uses: Swatinem/rust-cache@v2
113119
- uses: actions/checkout@v3
114120
- name: Run tests
@@ -129,12 +135,11 @@ jobs:
129135
- uses: hecrj/setup-rust-action@v1
130136
with:
131137
rust-version: ${{ matrix.rust }}
132-
components: rustfmt
133138
- uses: actions/checkout@v3
134-
- name: Install Protoc
135-
uses: arduino/setup-protoc@v1
139+
- name: Install protoc
140+
uses: taiki-e/install-action@v2
136141
with:
137-
repo-token: ${{ secrets.GITHUB_TOKEN }}
142+
tool: protoc@3.20.3
138143
- uses: Swatinem/rust-cache@v2
139144
- name: Run interop tests
140145
run: ./interop/test.sh

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [v0.9.2](https://github.com/hyperium/tonic/compare/v0.9.1...v0.9.2) (2023-04-17)
2+
3+
### Features
4+
5+
- **build:**: Support boxing fields ([#1252](https://github.com/hyperium/tonic/pull/1252))
6+
7+
18
# [v0.9.1](https://github.com/hyperium/tonic/compare/v0.9.0...v0.9.1) (2023-04-03)
29

310
### Features

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ members = [
2323
"tests/compression",
2424
"tonic-web/tests/integration",
2525
"tests/service_named_result",
26+
"tests/use_arc_self",
2627
]
2728
resolver = "2"

interop/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros"]}
2929
tokio-stream = "0.1"
3030
tonic = {path = "../tonic", features = ["tls"]}
3131
tower = {version = "0.4"}
32-
tracing = "0.1"
33-
tracing-log = "0.1"
34-
tracing-subscriber = {version = "0.3", features = ["env-filter"]}
32+
tracing-subscriber = {version = "0.3"}
3533

3634
[build-dependencies]
3735
tonic-build = {path = "../tonic-build", features = ["prost"]}

interop/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ pub mod pb {
1212
use std::{default, fmt, iter};
1313

1414
pub fn trace_init() {
15-
let sub = tracing_subscriber::FmtSubscriber::builder()
16-
.with_env_filter(tracing_subscriber::filter::EnvFilter::from_default_env())
17-
.finish();
18-
19-
let _ = tracing::subscriber::set_global_default(sub);
20-
let _ = tracing_log::LogTracer::init();
15+
tracing_subscriber::fmt::init();
2116
}
2217

2318
pub fn client_payload(size: usize) -> pb::Payload {

tests/integration_tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ futures-util = "0.3"
1414
prost = "0.11"
1515
tokio = {version = "1.0", features = ["macros", "rt-multi-thread", "net"]}
1616
tonic = {path = "../../tonic"}
17-
tracing-subscriber = {version = "0.3", features = ["env-filter"]}
17+
tracing-subscriber = {version = "0.3"}
1818

1919
[dev-dependencies]
2020
async-stream = "0.3"

tests/integration_tests/proto/test.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ message Output {}
1111

1212
service Test1 {
1313
rpc UnaryCall(Input1) returns (Output1);
14+
15+
rpc StreamCall(Input1) returns (stream Output1);
1416
}
1517

1618
message Input1 {

tests/integration_tests/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,5 @@ pub mod mock {
5555
}
5656

5757
pub fn trace_init() {
58-
let _ = tracing_subscriber::FmtSubscriber::builder()
59-
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
60-
.try_init();
58+
let _ = tracing_subscriber::fmt::try_init();
6159
}

tests/integration_tests/tests/max_message_size.rs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std::pin::Pin;
2+
3+
use futures::{stream, Stream};
14
use integration_tests::{
25
pb::{test1_client, test1_server, Input1, Output1},
36
trace_init,
@@ -110,6 +113,81 @@ fn max_message_send_size() {
110113
});
111114
}
112115

116+
#[tokio::test]
117+
async fn response_stream_limit() {
118+
let client_blob = vec![0; 1];
119+
120+
let (client, server) = tokio::io::duplex(1024);
121+
122+
struct Svc;
123+
124+
#[tonic::async_trait]
125+
impl test1_server::Test1 for Svc {
126+
async fn unary_call(&self, _req: Request<Input1>) -> Result<Response<Output1>, Status> {
127+
unimplemented!()
128+
}
129+
130+
type StreamCallStream =
131+
Pin<Box<dyn Stream<Item = Result<Output1, Status>> + Send + 'static>>;
132+
133+
async fn stream_call(
134+
&self,
135+
_req: Request<Input1>,
136+
) -> Result<Response<Self::StreamCallStream>, Status> {
137+
let blob = Output1 {
138+
buf: vec![0; 6877902],
139+
};
140+
let stream = stream::iter(vec![Ok(blob.clone()), Ok(blob.clone())]);
141+
142+
Ok(Response::new(Box::pin(stream)))
143+
}
144+
}
145+
146+
let svc = test1_server::Test1Server::new(Svc);
147+
148+
tokio::spawn(async move {
149+
Server::builder()
150+
.add_service(svc)
151+
.serve_with_incoming(futures::stream::iter(vec![Ok::<_, std::io::Error>(server)]))
152+
.await
153+
.unwrap();
154+
});
155+
156+
// Move client to an option so we can _move_ the inner value
157+
// on the first attempt to connect. All other attempts will fail.
158+
let mut client = Some(client);
159+
let channel = Endpoint::try_from("http://[::]:50051")
160+
.unwrap()
161+
.connect_with_connector(tower::service_fn(move |_| {
162+
let client = client.take();
163+
164+
async move {
165+
if let Some(client) = client {
166+
Ok(client)
167+
} else {
168+
Err(std::io::Error::new(
169+
std::io::ErrorKind::Other,
170+
"Client already taken",
171+
))
172+
}
173+
}
174+
}))
175+
.await
176+
.unwrap();
177+
178+
let client = test1_client::Test1Client::new(channel);
179+
180+
let mut client = client.max_decoding_message_size(6877902 + 5);
181+
182+
let req = Request::new(Input1 {
183+
buf: client_blob.clone(),
184+
});
185+
186+
let mut stream = client.stream_call(req).await.unwrap().into_inner();
187+
188+
while let Some(_b) = stream.message().await.unwrap() {}
189+
}
190+
113191
// Track caller doesn't work on async fn so we extract the async part
114192
// into a sync version and assert the response there using track track_caller
115193
// so that when this does panic it tells us which line in the test failed not
@@ -210,6 +288,16 @@ async fn max_message_run(case: &TestCase) -> Result<(), Status> {
210288
buf: self.0.clone(),
211289
}))
212290
}
291+
292+
type StreamCallStream =
293+
Pin<Box<dyn Stream<Item = Result<Output1, Status>> + Send + 'static>>;
294+
295+
async fn stream_call(
296+
&self,
297+
_req: Request<Input1>,
298+
) -> Result<Response<Self::StreamCallStream>, Status> {
299+
unimplemented!()
300+
}
213301
}
214302

215303
let svc = test1_server::Test1Server::new(Svc(server_blob));

tests/integration_tests/tests/status.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ type Stream<T> =
130130

131131
#[tokio::test]
132132
async fn status_from_server_stream() {
133-
trace_init();
133+
integration_tests::trace_init();
134134

135135
struct Svc;
136136

@@ -178,7 +178,7 @@ async fn status_from_server_stream() {
178178

179179
#[tokio::test]
180180
async fn status_from_server_stream_with_source() {
181-
trace_init();
181+
integration_tests::trace_init();
182182

183183
let channel = Endpoint::try_from("http://[::]:50051")
184184
.unwrap()
@@ -193,9 +193,3 @@ async fn status_from_server_stream_with_source() {
193193
let source = error.source().unwrap();
194194
source.downcast_ref::<tonic::transport::Error>().unwrap();
195195
}
196-
197-
fn trace_init() {
198-
let _ = tracing_subscriber::FmtSubscriber::builder()
199-
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
200-
.try_init();
201-
}

0 commit comments

Comments
 (0)