cdjingit edited a comment on issue #685: Thrift 
protocol中序列化的请求时,writeStructBegin 和 writeFieldBegin中的服务名和请求的名是固定的。无法定制
URL: https://github.com/apache/incubator-brpc/issues/685#issuecomment-472372750
 
 
   因为有些服务server端的实现不是基于brpc的。比如,我们现在开发brpc支持cassandra thrift,
   就有很多不同的方法和请求名称。
   这里似乎应该直接调用req->raw_instance()->Write(oport) 。直接写入整个请求的struct,就可以。比如
   /example/thrift_extension_c++/gen-cpp的例子
   
   ```
   179 void EchoServiceClient::send_Echo(const EchoRequest& request)
   180 {
   181   int32_t cseqid = 0;
   182   oprot_->writeMessageBegin("Echo", ::apache::thrift::protocol::T_CALL, 
cseqid);
   183 
   184   EchoService_Echo_pargs args;  
   185   args.request = &request;  
   186   args.write(oprot_);  // args作为raw_instance()传入 直接调用thrift生成的代码写入就可以
   187 
   188   oprot_->writeMessageEnd();
   189   oprot_->getTransport()->writeEnd();
   190   oprot_->getTransport()->flush();
   191 }
   
   ```
   @kenshinxf 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to