Return complete meta information of HEAD. (#123)

* Return complete meta information of HEAD.
* Fixes the CI by revisiting the LD_LIBRARY_PATH.

Signed-off-by: Tao He <sighingnow@gmail.com>
This commit is contained in:
Tao He 2022-04-06 16:01:49 +08:00 committed by GitHub
parent 767f0b1c65
commit d4975f84b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 62 additions and 5 deletions

View File

@ -129,7 +129,7 @@ jobs:
- name: Build - name: Build
run: | run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu
mkdir -p build mkdir -p build
cd build cd build
@ -148,7 +148,7 @@ jobs:
- name: Test - name: Test
run: | run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu
# use etcd v3 api # use etcd v3 api
export ETCDCTL_API="3" export ETCDCTL_API="3"
@ -171,7 +171,7 @@ jobs:
- name: Authentication Test - name: Authentication Test
run: | run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu
# use etcd v3 api # use etcd v3 api
export ETCDCTL_API="3" export ETCDCTL_API="3"
@ -212,7 +212,7 @@ jobs:
- name: Transport Security and Authentication Test - name: Transport Security and Authentication Test
run: | run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu
# use etcd v3 api # use etcd v3 api
export ETCDCTL_API="3" export ETCDCTL_API="3"

View File

@ -31,7 +31,7 @@ option(BUILD_ETCD_TESTS "Build test cases" OFF)
# reference: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#always-full-rpath # reference: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#always-full-rpath
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:${CMAKE_INSTALL_PREFIX}/lib/x86_64-linux-gnu")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(MSVC) if(MSVC)

View File

@ -171,6 +171,21 @@ namespace etcd
*/ */
std::chrono::microseconds const & duration() const; std::chrono::microseconds const & duration() const;
/**
* Returns the current cluster id.
*/
uint64_t cluster_id() const;
/**
* Returns the current member id.
*/
uint64_t member_id() const;
/**
* Returns ther current raft term.
*/
uint64_t raft_term() const;
protected: protected:
Response(const etcdv3::V3Response& response, std::chrono::microseconds const& duration); Response(const etcdv3::V3Response& response, std::chrono::microseconds const& duration);
Response(int error_code, char const * error_message); Response(int error_code, char const * error_message);
@ -190,6 +205,10 @@ namespace etcd
// execute duration (in microseconds), during the action created and response parsed // execute duration (in microseconds), during the action created and response parsed
std::chrono::microseconds _duration; std::chrono::microseconds _duration;
uint64_t _cluster_id;
uint64_t _member_id;
uint64_t _raft_term;
friend class Client; friend class Client;
friend class SyncClient; friend class SyncClient;
friend class etcdv3::AsyncWatchAction; friend class etcdv3::AsyncWatchAction;

View File

@ -31,6 +31,9 @@ namespace etcdv3
void set_name(std::string const &name); void set_name(std::string const &name);
std::string const &get_name() const; std::string const &get_name() const;
std::vector<mvccpb::Event> const & get_events() const; std::vector<mvccpb::Event> const & get_events() const;
uint64_t get_cluster_id() const;
uint64_t get_member_id() const;
uint64_t get_raft_term() const;
protected: protected:
int error_code; int error_code;
int64_t index; int64_t index;
@ -44,6 +47,9 @@ namespace etcdv3
std::string lock_key; // for lock std::string lock_key; // for lock
std::string name; // for campaign (in v3election) std::string name; // for campaign (in v3election)
std::vector<mvccpb::Event> events; // for watch std::vector<mvccpb::Event> events; // for watch
uint64_t cluster_id;
uint64_t member_id;
uint64_t raft_term;
}; };
} }
#endif #endif

View File

@ -34,6 +34,11 @@ etcd::Response::Response(const etcdv3::V3Response& reply, std::chrono::microseco
// duration // duration
_duration = duration; _duration = duration;
// etcd head
_cluster_id = reply.get_cluster_id();
_member_id = reply.get_member_id();
_raft_term = reply.get_raft_term();
} }
@ -130,3 +135,15 @@ std::vector<etcd::Event> const & etcd::Response::events() const {
std::chrono::microseconds const& etcd::Response::duration() const { std::chrono::microseconds const& etcd::Response::duration() const {
return this->_duration; return this->_duration;
} }
uint64_t etcd::Response::cluster_id() const {
return this->_cluster_id;
}
uint64_t etcd::Response::member_id() const {
return this->_member_id;
}
uint64_t etcd::Response::raft_term() const {
return this->_raft_term;
}

View File

@ -4,5 +4,8 @@
void etcdv3::AsyncHeadResponse::ParseResponse(RangeResponse& resp) void etcdv3::AsyncHeadResponse::ParseResponse(RangeResponse& resp)
{ {
cluster_id = resp.header().cluster_id();
member_id = resp.header().member_id();
index = resp.header().revision(); index = resp.header().revision();
raft_term = resp.header().raft_term();
} }

View File

@ -85,3 +85,15 @@ std::string const & etcdv3::V3Response::get_name() const {
std::vector<mvccpb::Event> const & etcdv3::V3Response::get_events() const { std::vector<mvccpb::Event> const & etcdv3::V3Response::get_events() const {
return this->events; return this->events;
} }
uint64_t etcdv3::V3Response::get_cluster_id() const {
return this->cluster_id;
}
uint64_t etcdv3::V3Response::get_member_id() const {
return this->member_id;
}
uint64_t etcdv3::V3Response::get_raft_term() const {
return this->raft_term;
}