jamesge commented on issue #692: Add Mysql Protocol, only support text protocol 
now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-480675997
 
 
   > 我考虑了一下,事务放在一次rpc里面可能支持的不够完善。比如这样的场景: 这个事务有两个操作,(1)查询记录1(2)根据1的查询结果,修改记录2。
   > 这种情景,用户可以根据一个事务的前几个语句对该事务后边的操作做一些逻辑判断,所以前边的结果得在事务结束前需要返回给用户。
   
   如果commands之间的代码介入不可避免,我觉得也ok,但是这里的使用要更加直觉化一些。一种方案如下:
   ```
   auto tx = brpc::NewMysqlTransaction(...);  // args can be replaced with 
MysqlTransactionOptions to apply more configurations.
   ...
   brpc::MysqlRequest crudReq(tx);  // the request is bound to `tx'
   brpc::MysqlResponse curdRsp;
   brpc::Controller crudCntl;
   crudReq.Query("...sql statement...");
   channel.CallMethod(NULL, &crudCntl, &crudReq, &curdRsp, NULL);
   ...
   delete tx;  // calls tx->End() automatically, or user can call tx->End() 
manually and delete tx later.
   ```

----------------------------------------------------------------
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