diff --git a/etcd/Response.hpp b/etcd/Response.hpp index 2501acd..ad73262 100644 --- a/etcd/Response.hpp +++ b/etcd/Response.hpp @@ -130,6 +130,12 @@ namespace etcd */ std::string const & key(int index) const; + /** + * Returns the compact_revision if the response is a watch-cancelled revision. + * `-1` means uninitialized (the response is not watch-cancelled) + */ + int compact_revision() const; + /** * Returns the lock key. */ @@ -162,6 +168,7 @@ namespace etcd Value _prev_value; Values _values; Keys _keys; + int _compact_revision = -1; // for watch std::string _lock_key; // for lock std::string _name; // for campaign (in v3election) std::vector _events; // for watch diff --git a/etcd/v3/V3Response.hpp b/etcd/v3/V3Response.hpp index 0bd0f17..b722922 100644 --- a/etcd/v3/V3Response.hpp +++ b/etcd/v3/V3Response.hpp @@ -25,6 +25,7 @@ namespace etcdv3 etcdv3::KeyValue const & get_value() const; etcdv3::KeyValue const & get_prev_value() const; bool has_values() const; + int get_compact_revision() const; void set_lock_key(std::string const &key); std::string const &get_lock_key() const; void set_name(std::string const &name); @@ -39,6 +40,7 @@ namespace etcdv3 etcdv3::KeyValue prev_value; std::vector values; std::vector prev_values; + int compact_revision = -1; std::string lock_key; // for lock std::string name; // for campaign (in v3election) std::vector events; // for watch diff --git a/src/Response.cpp b/src/Response.cpp index 93a0494..8b6a996 100644 --- a/src/Response.cpp +++ b/src/Response.cpp @@ -24,6 +24,7 @@ etcd::Response::Response(const etcdv3::V3Response& reply, std::chrono::microseco } _prev_value = Value(reply.get_prev_value()); + _compact_revision = reply.get_compact_revision(); _lock_key = reply.get_lock_key(); _name = reply.get_name(); @@ -109,6 +110,11 @@ std::string const & etcd::Response::key(int index) const return _keys[index]; } +int etcd::Response::compact_revision() const +{ + return _compact_revision; +} + std::string const & etcd::Response::lock_key() const { return _lock_key; } diff --git a/src/v3/AsyncWatchAction.cpp b/src/v3/AsyncWatchAction.cpp index ef630de..35d8f73 100644 --- a/src/v3/AsyncWatchAction.cpp +++ b/src/v3/AsyncWatchAction.cpp @@ -149,8 +149,10 @@ void etcdv3::AsyncWatchAction::waitForResponse(std::function 0; } +int etcdv3::V3Response::get_compact_revision() const +{ + return compact_revision; +} + void etcdv3::V3Response::set_lock_key(std::string const &key) { this->lock_key = key; }