8 #include <google/protobuf/message.h> 10 #include "absl/strings/string_view.h" 11 #include "util/status.h" 23 uint32_t async_level = 0;
26 using Message = ::google::protobuf::Message;
27 using StreamItemWriter = std::function<void(
const Message*)>;
28 using RpcMethodCb = std::function<
util::Status(
const Message&, Message* msg) noexcept>;
29 using RpcStreamMethodCb = std::function<
util::Status(
const Message&, StreamItemWriter) noexcept>;
35 virtual size_t GetMethodByHash(absl::string_view method)
const = 0;
38 return methods_.size();
41 void SetOptions(
size_t index,
const MethodOptions& opts);
52 RpcMethodCb single_rpc_method;
53 RpcStreamMethodCb stream_rpc_method;
56 const Message* default_req =
nullptr;
57 const Message* default_resp =
nullptr;
60 Method(std::string n, RpcMethodCb c,
const Message& dreq,
const Message& dresp)
62 single_rpc_method(std::move(c)),
64 default_resp(&dresp) {
68 Method(std::string n, RpcStreamMethodCb c,
const Message& dreq)
69 : name(std::move(n)), stream_rpc_method(std::move(c)), default_req(&dreq) {
73 const Method& method(
size_t i)
const {
78 std::vector<Method> methods_;