Skip to content

Commit

Permalink
Merge branch 'master' into remove-unnecessary-code
Browse files Browse the repository at this point in the history
  • Loading branch information
LucioFranco authored Nov 15, 2023
2 parents 1f3624c + 53267a3 commit c2b4bc3
Show file tree
Hide file tree
Showing 54 changed files with 432 additions and 380 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: hecrj/setup-rust-action@v1
- uses: hecrj/setup-rust-action@v2
with:
components: rustfmt
- run: cargo fmt --all --check
Expand All @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: hecrj/setup-rust-action@v1
- uses: hecrj/setup-rust-action@v2
- name: Install protoc
uses: taiki-e/install-action@v2
with:
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: hecrj/setup-rust-action@v1
- uses: hecrj/setup-rust-action@v2
- uses: taiki-e/install-action@cargo-hack
- name: Install protoc
uses: taiki-e/install-action@v2
Expand All @@ -86,9 +86,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: hecrj/setup-rust-action@v1
- uses: hecrj/setup-rust-action@v2
with:
rust-version: "1.64" # msrv
rust-version: "1.65" # msrv
- name: Install protoc
uses: taiki-e/install-action@v2
with:
Expand All @@ -106,7 +106,7 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: hecrj/setup-rust-action@v1
- uses: hecrj/setup-rust-action@v2
- name: Install protoc
uses: taiki-e/install-action@v2
with:
Expand All @@ -124,7 +124,7 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: hecrj/setup-rust-action@v1
- uses: hecrj/setup-rust-action@v2
- name: Install protoc
uses: taiki-e/install-action@v2
with:
Expand Down
266 changes: 125 additions & 141 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ For IntelliJ IDEA users, please refer to [this](https://github.com/intellij-rust

### Rust Version

`tonic`'s MSRV is `1.64`.
`tonic`'s MSRV is `1.65`.

```bash
$ rustup update
Expand Down
12 changes: 6 additions & 6 deletions codegen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::path::{Path, PathBuf};

fn main() {
// tonic-health
Expand Down Expand Up @@ -45,11 +45,11 @@ fn main() {
}

fn codegen(
root_dir: &PathBuf,
root_dir: &Path,
iface_files: &[&str],
include_dirs: &[&str],
out_dir: &PathBuf,
file_descriptor_set_path: &PathBuf,
out_dir: &Path,
file_descriptor_set_path: &Path,
build_client: bool,
build_server: bool,
) {
Expand All @@ -59,12 +59,12 @@ fn codegen(
.unwrap();

let iface_files: Vec<PathBuf> = iface_files
.into_iter()
.iter()
.map(|&path| root_dir.join(path))
.collect();

let include_dirs: Vec<PathBuf> = include_dirs
.into_iter()
.iter()
.map(|&path| root_dir.join(path))
.collect();
let out_dir = root_dir.join(out_dir);
Expand Down
4 changes: 2 additions & 2 deletions examples/helloworld-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ name = "helloworld-client"
path = "src/client.rs"

[dependencies]
tonic = "0.9"
tonic = "0.10"
prost = "0.12"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }

[build-dependencies]
tonic-build = "0.9"
tonic-build = "0.10"
```

We include `tonic-build` as a useful way to incorporate the generation of our client and server gRPC code into the build process of our application. We will setup this build process now:
Expand Down
4 changes: 2 additions & 2 deletions examples/routeguide-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Edit `Cargo.toml` and add all the dependencies we'll need for this example:

```toml
[dependencies]
tonic = "0.9"
tonic = "0.10"
prost = "0.12"
tokio = { version = "1.0", features = ["rt-multi-thread", "macros", "sync", "time"] }
tokio-stream = "0.1"
Expand All @@ -185,7 +185,7 @@ serde_json = "1.0"
rand = "0.7"

[build-dependencies]
tonic-build = "0.9"
tonic-build = "0.10"
```

Create a `build.rs` file at the root of your crate:
Expand Down
10 changes: 2 additions & 8 deletions examples/src/dynamic/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ impl Echo for MyEcho {
}

fn init_echo(args: &[String], builder: &mut RoutesBuilder) {
let enabled = args
.into_iter()
.find(|arg| arg.as_str() == "echo")
.is_some();
let enabled = args.iter().any(|arg| arg.as_str() == "echo");
if enabled {
println!("Adding Echo service...");
let svc = EchoServer::new(MyEcho::default());
Expand All @@ -62,10 +59,7 @@ impl Greeter for MyGreeter {
}

fn init_greeter(args: &[String], builder: &mut RoutesBuilder) {
let enabled = args
.into_iter()
.find(|arg| arg.as_str() == "greeter")
.is_some();
let enabled = args.iter().any(|arg| arg.as_str() == "greeter");

if enabled {
println!("Adding Greeter service...");
Expand Down
2 changes: 1 addition & 1 deletion examples/src/mock/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
tokio::spawn(async move {
Server::builder()
.add_service(GreeterServer::new(greeter))
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
});

Expand Down
2 changes: 1 addition & 1 deletion examples/src/richer-error/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
};

println!(" Successfull response received.\n\n {:?}\n", response);
println!(" Successful response received.\n\n {:?}\n", response);

Ok(())
}
2 changes: 1 addition & 1 deletion examples/src/richer-error/client_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
};

println!(" Successfull response received.\n\n {:?}\n", response);
println!(" Successful response received.\n\n {:?}\n", response);

Ok(())
}
6 changes: 3 additions & 3 deletions interop/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub async fn ping_pong(client: &mut TestClient, assertions: &mut Vec<TestAsserti
}

pub async fn empty_stream(client: &mut TestClient, assertions: &mut Vec<TestAssertion>) {
let stream = tokio_stream::iter(Vec::new());
let stream = tokio_stream::empty();
let result = client.full_duplex_call(Request::new(stream)).await;

assertions.push(test_assert!(
Expand Down Expand Up @@ -270,7 +270,7 @@ pub async fn status_code_and_message(client: &mut TestClient, assertions: &mut V
let result = client.unary_call(Request::new(simple_req)).await;
validate_response(result, assertions);

let stream = tokio_stream::iter(vec![duplex_req]);
let stream = tokio_stream::once(duplex_req);
let result = match client.full_duplex_call(Request::new(stream)).await {
Ok(response) => {
let stream = response.into_inner();
Expand Down Expand Up @@ -356,7 +356,7 @@ pub async fn custom_metadata(client: &mut TestClient, assertions: &mut Vec<TestA
req_unary.metadata_mut().insert(key1, value1.clone());
req_unary.metadata_mut().insert_bin(key2, value2.clone());

let stream = tokio_stream::iter(vec![make_ping_pong_request(0)]);
let stream = tokio_stream::once(make_ping_pong_request(0));
let mut req_stream = Request::new(stream);
req_stream.metadata_mut().insert(key1, value1.clone());
req_stream.metadata_mut().insert_bin(key2, value2.clone());
Expand Down
4 changes: 2 additions & 2 deletions interop/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::Duration;
use tokio_stream::StreamExt;
use tonic::{body::BoxBody, transport::NamedService, Code, Request, Response, Status};
use tonic::{body::BoxBody, server::NamedService, Code, Request, Response, Status};
use tower::Service;

pub use pb::test_service_server::TestServiceServer;
Expand Down Expand Up @@ -115,7 +115,7 @@ impl pb::test_service_server::TestService for TestService {
return Err(status);
}

let single_message = tokio_stream::iter(vec![Ok(first_msg)]);
let single_message = tokio_stream::once(Ok(first_msg));
let mut stream = single_message.chain(stream);

let stream = try_stream! {
Expand Down
2 changes: 1 addition & 1 deletion tests/compression/src/bidirectional_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn client_enabled_server_enabled() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand Down
11 changes: 5 additions & 6 deletions tests/compression/src/client_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async fn client_enabled_server_enabled() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand Down Expand Up @@ -75,7 +75,7 @@ async fn client_disabled_server_enabled() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand All @@ -102,7 +102,7 @@ async fn client_enabled_server_disabled() {
tokio::spawn(async move {
Server::builder()
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
});
Expand Down Expand Up @@ -147,7 +147,7 @@ async fn compressing_response_from_client_stream() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand All @@ -156,8 +156,7 @@ async fn compressing_response_from_client_stream() {
let mut client = test_client::TestClient::new(mock_io_channel(client).await)
.accept_compressed(CompressionEncoding::Gzip);

let stream = tokio_stream::iter(vec![]);
let req = Request::new(Box::pin(stream));
let req = Request::new(Box::pin(tokio_stream::empty()));

let res = client.compress_output_client_stream(req).await.unwrap();
assert_eq!(res.metadata().get("grpc-encoding").unwrap(), "gzip");
Expand Down
6 changes: 3 additions & 3 deletions tests/compression/src/compressing_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async fn client_enabled_server_enabled() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand Down Expand Up @@ -61,7 +61,7 @@ async fn client_enabled_server_disabled() {
tokio::spawn(async move {
Server::builder()
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
});
Expand Down Expand Up @@ -99,7 +99,7 @@ async fn client_mark_compressed_without_header_server_enabled() {
async move {
Server::builder()
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand Down
17 changes: 8 additions & 9 deletions tests/compression/src/compressing_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn client_enabled_server_enabled() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand Down Expand Up @@ -94,7 +94,7 @@ async fn client_enabled_server_disabled() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand Down Expand Up @@ -160,7 +160,7 @@ async fn client_disabled() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand Down Expand Up @@ -198,7 +198,7 @@ async fn server_replying_with_unsupported_encoding() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
});
Expand Down Expand Up @@ -240,7 +240,7 @@ async fn disabling_compression_on_single_response() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand Down Expand Up @@ -281,7 +281,7 @@ async fn disabling_compression_on_response_but_keeping_compression_on_stream() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand Down Expand Up @@ -337,7 +337,7 @@ async fn disabling_compression_on_response_from_client_stream() {
.into_inner(),
)
.add_service(svc)
.serve_with_incoming(tokio_stream::iter(vec![Ok::<_, std::io::Error>(server)]))
.serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
.await
.unwrap();
}
Expand All @@ -346,8 +346,7 @@ async fn disabling_compression_on_response_from_client_stream() {
let mut client = test_client::TestClient::new(mock_io_channel(client).await)
.accept_compressed(CompressionEncoding::Gzip);

let stream = tokio_stream::iter(vec![]);
let req = Request::new(Box::pin(stream));
let req = Request::new(Box::pin(tokio_stream::empty()));

let res = client.compress_output_client_stream(req).await.unwrap();
assert_eq!(res.metadata().get("grpc-encoding").unwrap(), "gzip");
Expand Down
Loading

0 comments on commit c2b4bc3

Please sign in to comment.