chenBright commented on PR #2946: URL: https://github.com/apache/brpc/pull/2946#issuecomment-2796527918
我觉得将序列化过程作为回调传到compress里,会更合适一些。 ```c++ // CompressCallback provides raw data for compression, // and a buffer for storing compressed data. class CompressCallback : public CompressBase { public: // Converts the data into `output' for later compression. virtual bool Convert(google::protobuf::io::ZeroCopyOutputStream* output) = 0; // Returns the buffer for storing compressed data. virtual butil::IOBuf& Buffer() = 0; }; // DecompressCallback provides raw data stored in a buffer for decompression, // and handles the decompressed data. class DecompressCallback : public CompressBase { public: // Converts the decompressed `input'. virtual bool Convert(google::protobuf::io::ZeroCopyInputStream* intput) = 0; // Returns the buffer containing compressed data. virtual const butil::IOBuf& Buffer() = 0; }; struct CompressHandler { // Compress data from CompressCallback::Convert() into CompressCallback::Buffer(). bool (*Compress)(CompressCallback& callback); // Decompress data from DecompressCallback::Buffer() into DecompressCallback::Convert(). bool (*Decompress)(DecompressCallback& callback); // Name of the compression algorithm, must be string constant. const char* name; }; ``` -- 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: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org