zengkui opened a new issue, #1775:
URL: https://github.com/apache/incubator-brpc/issues/1775

   我想尝试用brpc来访问etcd的kv服务,实现了一个put key 
value的功能,demo代码如下,功能是正常的,但是我想用brpc实现watch功能,就出现问题了。
   ```
   void PutKeyValue(brpc::Channel& channel) {
     brpc::Controller cntl;
     brpc::URI& uri = cntl.http_request().uri();
     uri.set_path("/v3/kv/put");
     cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
     butil::IOBufBuilder os;
     os << "{\"key\":\"Zm9v\",\"value\":\"YmFy\"}";
     os.move_to(cntl.request_attachment());
   
     channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
     if (cntl.Failed()) {
       std::cerr << cntl.ErrorText() << std::endl;
       return;
     }
     std::cout << cntl.response_attachment() << std::endl;
   }
   ```
   watch的demo代码如下, 调用CallMethod后,就一直阻塞在这个调用了,不知道这个watch机制应该怎么用brpc来实现? 
另外我的理解watch机制应该需要注册一个时间处理的函数,这个怎么实现了? 
   ```
   void Watch(brpc::Channel& channel) {
     brpc::Controller cntl;
     cntl.http_request().uri().set_path("/v3/watch");
     cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
     butil::IOBufBuilder os;
     os << "{\"create_request\": {\"key\":\"Zm9v\"}}";
     os.move_to(cntl.request_attachment());
   
     channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
     if (cntl.Failed()) {
       std::cerr << cntl.ErrorText() << std::endl;
       return;
     }
     std::cout << cntl.response_attachment() << std::endl;
     while (1) {sleep(1111111);}
   }
   ```


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

Reply via email to