chenBright commented on code in PR #2751:
URL: https://github.com/apache/brpc/pull/2751#discussion_r1741382570
##########
docs/en/server.md:
##########
@@ -1008,6 +1008,49 @@ public:
...
```
+## RPC Protobuf message factory
+
+`DefaultRpcPBMessageFactory' is used at server-side by default. It is a simple
factory class that uses `new' to create request/response messages and `delete'
to destroy request/response messages. Currently, the baidu_std protocol and
HTTP protocol support this feature.
+
+Users can implement `RpcPBMessages' (encapsulation of request/response
message) and `RpcPBMessageFactory' (factory class) to customize the creation
and destruction mechanism of protobuf message, and then set to
`ServerOptions.rpc_pb_message_factory`. Note: After the server is started, the
server owns the `RpcPBMessageFactory`.
+
+The interface is as follows:
+
+```c++
+// Inherit this class to customize rpc protobuf messages,
+// include request and response.
+class RpcPBMessages {
+public:
+ virtual ~RpcPBMessages() = default;
+ // Get protobuf request message.
+ virtual google::protobuf::Message* Request() = 0;
+ // Get protobuf response message.
+ virtual google::protobuf::Message* Response() = 0;
+};
+
+// Factory to manage `RpcPBMessages'.
+class RpcPBMessageFactory {
+public:
+ virtual ~RpcPBMessageFactory() = default;
+ // Get `RpcPBMessages' according to `service' and `method'.
+ // Common practice to create protobuf message:
+ // service.GetRequestPrototype(&method).New() -> request;
+ // service.GetRequestPrototype(&method).New() -> response.
Review Comment:
done
--
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]