chenBright commented on code in PR #3559:
URL: https://github.com/apache/brpc/pull/3559#discussion_r4469397324
##########
src/brpc/server.cpp:
##########
@@ -114,6 +119,71 @@ const char* status_str(Server::Status s) {
return "UNKNOWN_STATUS";
}
+#if BRPC_WITH_FLATBUFFERS
+struct Server::FlatBuffersServiceMap {
+ struct Method {
+ Method(flatbuffers::Service* service,
+ const flatbuffers::MethodDescriptor* descriptor)
+ : status(std::make_unique<MethodStatus>()) {
+ property.fb_service = service;
+ property.fb_method = descriptor;
+ property.status = status.get();
+ }
+
+ std::unique_ptr<MethodStatus> status;
+ // Same type as protobuf methods, so per-method options are shared.
+ MethodProperty property;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Method);
+ };
+ struct Service {
+ Service(flatbuffers::Service* svc,
+ const flatbuffers::ServiceDescriptor* desc)
+ : service(svc)
+ , descriptor(desc)
+ , ownership(SERVER_DOESNT_OWN_SERVICE) {}
+ ~Service() {
+ methods.clear();
+ if (ownership == SERVER_OWNS_SERVICE) {
+ delete service;
+ }
+ }
+
+ flatbuffers::Service* service;
+ const flatbuffers::ServiceDescriptor* descriptor;
+ ServiceOwnership ownership;
+ std::map<int32_t, std::unique_ptr<Method> > methods;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Service);
+ };
+ typedef std::map<uint32_t, std::unique_ptr<Service> > ServiceMap;
Review Comment:
Same as above.
##########
src/brpc/server.cpp:
##########
@@ -114,6 +119,71 @@ const char* status_str(Server::Status s) {
return "UNKNOWN_STATUS";
}
+#if BRPC_WITH_FLATBUFFERS
+struct Server::FlatBuffersServiceMap {
+ struct Method {
+ Method(flatbuffers::Service* service,
+ const flatbuffers::MethodDescriptor* descriptor)
+ : status(std::make_unique<MethodStatus>()) {
+ property.fb_service = service;
+ property.fb_method = descriptor;
+ property.status = status.get();
+ }
+
+ std::unique_ptr<MethodStatus> status;
+ // Same type as protobuf methods, so per-method options are shared.
+ MethodProperty property;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Method);
+ };
+ struct Service {
+ Service(flatbuffers::Service* svc,
+ const flatbuffers::ServiceDescriptor* desc)
+ : service(svc)
+ , descriptor(desc)
+ , ownership(SERVER_DOESNT_OWN_SERVICE) {}
+ ~Service() {
+ methods.clear();
+ if (ownership == SERVER_OWNS_SERVICE) {
+ delete service;
+ }
+ }
+
+ flatbuffers::Service* service;
+ const flatbuffers::ServiceDescriptor* descriptor;
+ ServiceOwnership ownership;
+ std::map<int32_t, std::unique_ptr<Method> > methods;
Review Comment:
Please use `std::unordered_map` instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]