Include watch_id in the response
Signed-off-by: Tao He <sighingnow@gmail.com>
This commit is contained in:
parent
0ed7bee2c8
commit
6b13dfbcc1
|
|
@ -161,6 +161,11 @@ namespace etcd
|
|||
*/
|
||||
int64_t compact_revision() const;
|
||||
|
||||
/**
|
||||
* Returns the watcher id for client.watch() requests. `-1` means uninitialized (the response is not for watch).
|
||||
*/
|
||||
int64_t watch_id() const;
|
||||
|
||||
/**
|
||||
* Returns the lock key.
|
||||
*/
|
||||
|
|
@ -215,6 +220,7 @@ namespace etcd
|
|||
Values _values;
|
||||
Keys _keys;
|
||||
int64_t _compact_revision = -1; // for watch
|
||||
int64_t _watch_id = -1; // for watch
|
||||
std::string _lock_key; // for lock
|
||||
std::string _name; // for campaign (in v3election)
|
||||
std::vector<Event> _events; // for watch
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ namespace etcdv3
|
|||
etcdv3::KeyValue const & get_prev_value() const;
|
||||
bool has_values() const;
|
||||
int64_t get_compact_revision() const;
|
||||
void set_compact_revision(const int64_t compact_revision);
|
||||
int64_t get_watch_id() const;
|
||||
void set_watch_id(const int64_t watch_id);
|
||||
void set_lock_key(std::string const &key);
|
||||
std::string const &get_lock_key() const;
|
||||
void set_name(std::string const &name);
|
||||
|
|
@ -45,6 +48,7 @@ namespace etcdv3
|
|||
std::vector<etcdv3::KeyValue> values;
|
||||
std::vector<etcdv3::KeyValue> prev_values;
|
||||
int64_t compact_revision = -1;
|
||||
int64_t watch_id = -1;
|
||||
std::string lock_key; // for lock
|
||||
std::string name; // for campaign (in v3election)
|
||||
std::vector<mvccpb::Event> events; // for watch
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ etcd::Response::Response(const etcdv3::V3Response& reply, std::chrono::microseco
|
|||
_prev_value = Value(reply.get_prev_value());
|
||||
|
||||
_compact_revision = reply.get_compact_revision();
|
||||
_watch_id = reply.get_watch_id();
|
||||
_lock_key = reply.get_lock_key();
|
||||
_name = reply.get_name();
|
||||
|
||||
|
|
@ -156,6 +157,11 @@ int64_t etcd::Response::compact_revision() const
|
|||
return _compact_revision;
|
||||
}
|
||||
|
||||
int64_t etcd::Response::watch_id() const
|
||||
{
|
||||
return _watch_id;
|
||||
}
|
||||
|
||||
std::string const & etcd::Response::lock_key() const {
|
||||
return _lock_key;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,7 +261,6 @@ void etcdv3::AsyncWatchResponse::ParseResponse(WatchResponse& reply)
|
|||
action = etcdv3::SET_ACTION;
|
||||
}
|
||||
value.kvs = event.kv();
|
||||
|
||||
}
|
||||
else if(mvccpb::Event::EventType::Event_EventType_DELETE_ == event.type())
|
||||
{
|
||||
|
|
@ -1355,6 +1354,7 @@ etcdv3::AsyncWatchResponse etcdv3::AsyncWatchAction::ParseResponse()
|
|||
{
|
||||
AsyncWatchResponse watch_resp;
|
||||
watch_resp.set_action(etcdv3::WATCH_ACTION);
|
||||
watch_resp.set_watch_id(reply.watch_id());
|
||||
|
||||
if(!status.ok())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,6 +66,21 @@ int64_t etcdv3::V3Response::get_compact_revision() const
|
|||
return compact_revision;
|
||||
}
|
||||
|
||||
void etcdv3::V3Response::set_compact_revision(const int64_t compact_revision)
|
||||
{
|
||||
this->compact_revision = compact_revision;
|
||||
}
|
||||
|
||||
int64_t etcdv3::V3Response::get_watch_id() const
|
||||
{
|
||||
return watch_id;
|
||||
}
|
||||
|
||||
void etcdv3::V3Response::set_watch_id(const int64_t watch_id)
|
||||
{
|
||||
this->watch_id = watch_id;
|
||||
}
|
||||
|
||||
void etcdv3::V3Response::set_lock_key(std::string const &key) {
|
||||
this->lock_key = key;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue