feat(build): support adding attributes to clients and servers (#684)

This commit is contained in:
Conner Bryan
2021-07-08 15:01:28 -04:00
committed by GitHub
parent 89df3380dd
commit a948a8f884
6 changed files with 216 additions and 12 deletions
+8
View File
@@ -15,6 +15,14 @@ fn main() {
tonic_build::compile_protos("proto/echo/echo.proto").unwrap();
tonic_build::configure()
.server_mod_attribute("attrs", "#[cfg(feature = \"server\")]")
.server_attribute("Echo", "#[derive(PartialEq)]")
.client_mod_attribute("attrs", "#[cfg(feature = \"client\")]")
.client_attribute("Echo", "#[derive(PartialEq)]")
.compile(&["proto/attrs/attrs.proto"], &["proto"])
.unwrap();
tonic_build::configure()
.build_server(false)
.compile(
+19
View File
@@ -0,0 +1,19 @@
syntax = "proto3";
package attrs;
// EchoRequest is the request for echo.
message EchoRequest {
string message = 1;
}
// EchoResponse is the response for echo.
message EchoResponse {
string message = 1;
}
// Echo is the echo service.
service Echo {
// UnaryEcho is unary echo.
rpc UnaryEcho(EchoRequest) returns (EchoResponse) {}
}