This is an automated email from the ASF dual-hosted git repository.
mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git
The following commit(s) were added to refs/heads/develop by this push:
new c0b7e94 [rpc] Add APIs to get/set metadata of request
c0b7e94 is described below
commit c0b7e94ef3ecbef8a52632bd9501555beffd9307
Author: Mingshen Sun <[email protected]>
AuthorDate: Thu Feb 13 16:26:05 2020 -0800
[rpc] Add APIs to get/set metadata of request
---
rpc/src/request.rs | 10 ++++++++--
services/proto/proto_gen/templates/proto.j2 | 8 ++++++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/rpc/src/request.rs b/rpc/src/request.rs
index 0931e2e..b3b8f48 100644
--- a/rpc/src/request.rs
+++ b/rpc/src/request.rs
@@ -18,9 +18,7 @@ impl<T> Request<T> {
message,
}
}
-}
-impl<T> Request<T> {
pub fn map<F, U>(self, f: F) -> Request<U>
where
F: FnOnce(T) -> U,
@@ -32,4 +30,12 @@ impl<T> Request<T> {
message,
}
}
+
+ pub fn metadata(&self) -> &HashMap<String, String> {
+ &self.metadata
+ }
+
+ pub fn metadata_mut(&mut self) -> &mut HashMap<String, String> {
+ &mut self.metadata
+ }
}
diff --git a/services/proto/proto_gen/templates/proto.j2
b/services/proto/proto_gen/templates/proto.j2
index 70c16fd..9bf279e 100644
--- a/services/proto/proto_gen/templates/proto.j2
+++ b/services/proto/proto_gen/templates/proto.j2
@@ -96,4 +96,12 @@ impl {{ service.proto_name }}Client {
}
}
{%- endfor %}
+
+ pub fn metadata(&self) -> &std::collections::HashMap<std::string::String,
std::string::String> {
+ &self.metadata
+ }
+
+ pub fn metadata_mut(&mut self) -> &mut
std::collections::HashMap<std::string::String, std::string::String> {
+ &mut self.metadata
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]