Skip to content

Commit

Permalink
rust: compile gRPC bindings with Tonic (#4317)
Browse files Browse the repository at this point in the history
Summary:
This patch switches our Rust protocol buffer bindings from `prost-build`
to `tonic-build`. This generates the same protobuf message types, since
Tonic interoperates with Prost, but can now also generate gRPC stubs.

Test Plan:
Check the doc server to see that our existing proto types still look
good, in the `rustboard_core::proto::tensorboard` package. We don’t have
gRPC services to generate yet, so our existing generated code hasn’t
changed. A follow-up commit will add a demo server as proof of concept.

wchargin-branch: rust-compile-grpc
  • Loading branch information
wchargin authored Nov 12, 2020
1 parent 15ff62f commit 1fbc436
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tensorboard/data/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ rust_library(
"//third_party/rust:prost",
"//third_party/rust:rand",
"//third_party/rust:rand_chacha",
"//third_party/rust:tonic",
],
)

Expand Down Expand Up @@ -89,7 +90,7 @@ rust_binary(
edition = "2018",
visibility = ["//visibility:private"],
deps = [
"//third_party/rust:prost_build",
"//third_party/rust:tonic_build",
],
)

Expand Down
5 changes: 3 additions & 2 deletions tensorboard/data/server/gen_protos_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ fn main() -> std::io::Result<()> {
dir.push("genproto");
dir
};
prost_build::Config::new()
tonic_build::configure()
.out_dir(&out_dir)
.compile_protos(&["tensorboard/compat/proto/event.proto"], &["."])
.format(false) // don't run `rustfmt`; shouldn't be needed to build
.compile(&["tensorboard/compat/proto/event.proto"], &["."])
.expect("compile_protos");
Ok(())
}

0 comments on commit 1fbc436

Please sign in to comment.