etcd-io / etcd

Distributed reliable key-value store for the most critical data of a distributed system
https://etcd.io
Apache License 2.0
47.84k stars 9.77k forks source link

WatchResponse result string in restful NOT align to it's protobuf definition #14089

Closed zengkui closed 2 years ago

zengkui commented 2 years ago

I want to access etcd restfull api with cpp client. In watch request, my demo code as follow runs ok.

  etcdserverpb::WatchRequest wr;
  auto* create_request = wr.mutable_create_request();
  create_request->set_key(watch_key);
  create_request->set_range_end(range_end);
  std::string output;
  auto status = google::protobuf::util::MessageToJsonString(wr, &output);

but in the response stage, I just found the function JsonStringToMessage returned fail cause the structure of response string does not align to WatchResponse

::etcdserverpb::WatchResponse response;
auto status = google::protobuf::util::JsonStringToMessage(os_.to_string(), &response);
LOG(INFO) << status  << " response "  << response.DebugString();

the correct WatchResponse should has a field named 'result', and all content wrapped in it.

message WatchResponseEx {
  WatchResponse result = 1;
}

Could such a definition be added to the proto file for convenience?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.