Skip to content

Commit 18cc8bf

Browse files
committed
fix(examples): 修复grpc相关示例
我修复grpc、grpc_h2c、grpc_streaming三个示例\n- 同步更新各示例的Cargo.toml与build.rs\n- 解决示例构建与运行问题,确保cargo check通过
1 parent 90fd29e commit 18cc8bf

File tree

7 files changed

+33
-29
lines changed

7 files changed

+33
-29
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ tokio-stream = {version = "0.1", features = ["net"]}
3131
tokio-tungstenite = "0.27"
3232
tokio_wasi = {version = "1", features = ["full"]}
3333
tonic = "0.14"
34-
tonic-build = "0.14"
34+
tonic-prost = "0.14"
35+
tonic-prost-build = "0.14"
3536
tower = "0.5"
3637
tracing-subscriber = "0.3"
3738
uuid = {version = "1", features = ["serde", "v4"]}

examples/grpc/Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
[package]
2-
name = "example-grpc"
3-
edition.workspace = true
42
authors.workspace = true
3+
edition.workspace = true
54
homepage.workspace = true
65
license.workspace = true
6+
name = "example-grpc"
7+
publish = false
78
readme.workspace = true
89
repository.workspace = true
910
version.workspace = true
10-
publish = false
1111

1212
[[bin]]
1313
name = "example-grpc-client"
1414
path = "src/client.rs"
1515

1616
[dependencies]
17-
tonic.workspace = true
18-
prost.workspace = true
19-
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
20-
silent = { path = "../../silent", features = ["grpc"] }
2117
async-trait.workspace = true
18+
prost.workspace = true
19+
silent = {path = "../../silent", features = ["grpc"]}
20+
tokio = {workspace = true, features = ["macros", "rt-multi-thread"]}
21+
tonic-prost.workspace = true
22+
tonic.workspace = true
2223

2324
[build-dependencies]
24-
tonic-build = { version = "0.14" }
25+
tonic-prost-build.workspace = true

examples/grpc/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn main() {
2-
tonic_build::configure()
2+
tonic_prost_build::configure()
33
.compile_protos(&["proto/hello_world.proto"], &["/proto"])
44
.unwrap();
55
}

examples/grpc_h2c/Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
[package]
2-
name = "example-grpc-h2c"
3-
edition.workspace = true
42
authors.workspace = true
3+
edition.workspace = true
54
homepage.workspace = true
65
license.workspace = true
6+
name = "example-grpc-h2c"
7+
publish = false
78
readme.workspace = true
89
repository.workspace = true
910
version.workspace = true
10-
publish = false
1111

1212
[[bin]]
1313
name = "example-grpc-client"
1414
path = "src/client.rs"
1515

1616
[dependencies]
17-
tonic.workspace = true
18-
prost.workspace = true
19-
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
20-
silent = { path = "../../silent", features = ["grpc"] }
2117
async-trait.workspace = true
2218
http.workspace = true
2319
hyper-util.workspace = true
2420
hyper.workspace = true
21+
prost.workspace = true
22+
silent = {path = "../../silent", features = ["grpc"]}
23+
tokio = {workspace = true, features = ["macros", "rt-multi-thread"]}
24+
tonic-prost.workspace = true
25+
tonic.workspace = true
2526
tower.workspace = true
2627

2728
[build-dependencies]
28-
tonic-build.workspace = true
29+
tonic-prost-build.workspace = true

examples/grpc_h2c/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{env, path::PathBuf};
33
fn main() {
44
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
55

6-
tonic_build::configure()
6+
tonic_prost_build::configure()
77
.file_descriptor_set_path(out_dir.join("hello_world_descriptor.bin"))
88
.compile_protos(&["proto/hello_world.proto"], &["/proto"])
99
.unwrap();

examples/grpc_streaming/Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
[package]
2-
name = "example-grpc-streaming"
3-
edition.workspace = true
42
authors.workspace = true
3+
edition.workspace = true
54
homepage.workspace = true
65
license.workspace = true
6+
name = "example-grpc-streaming"
7+
publish = false
78
readme.workspace = true
89
repository.workspace = true
910
version.workspace = true
10-
publish = false
1111

1212
[[bin]]
1313
name = "example-grpc-client"
1414
path = "src/client.rs"
1515

1616
[dependencies]
17-
tonic.workspace = true
18-
prost.workspace = true
19-
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
20-
silent = { path = "../../silent", features = ["grpc"] }
2117
async-trait.workspace = true
22-
tokio-stream.workspace = true
2318
h2.workspace = true
19+
prost.workspace = true
20+
silent = {path = "../../silent", features = ["grpc"]}
21+
tokio = {workspace = true, features = ["macros", "rt-multi-thread"]}
22+
tokio-stream.workspace = true
23+
tonic-prost.workspace = true
24+
tonic.workspace = true
2425

2526
[build-dependencies]
26-
tonic-build = { version = "0.14" }
27+
tonic-prost-build.workspace = true

examples/grpc_streaming/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn main() {
2-
tonic_build::configure()
2+
tonic_prost_build::configure()
33
.compile_protos(&["proto/echo.proto"], &["/proto"])
44
.unwrap();
55
}

0 commit comments

Comments
 (0)