Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Return server state in debug response.
kishorenc6342465a30cc
diff --git a/include/http_server.h b/include/http_server.hindex ac825a3b..650999e3 100644--- a/include/http_server.h+++ b/include/http_server.h@@ -93,6 +93,8 @@ public:bool is_alive() const;+ uint64_t node_state() const;+void set_auth_handler(bool (*handler)(http_req & req, const route_path & rpath,const std::string & auth_key));diff --git a/include/raft_server.h b/include/raft_server.hindex d7ce6f33..1866af3b 100644--- a/include/raft_server.h+++ b/include/raft_server.h@@ -126,6 +126,8 @@ public:bool is_alive() const;+ uint64_t node_state() const;+// Shut this node down.void shutdown() {if (node) {diff --git a/src/core_api.cpp b/src/core_api.cppindex 999f65ff..8f5a1e83 100644--- a/src/core_api.cpp+++ b/src/core_api.cpp@@ -184,8 +184,11 @@ bool del_drop_collection(http_req & req, http_res & res) {bool get_debug(http_req & req, http_res & res) {nlohmann::json result;result["version"] = server->get_version();- res.set_200(result.dump());+ uint64_t state = server->node_state();+ result["state"] = state;++ res.set_200(result.dump());return true;}diff --git a/src/http_server.cpp b/src/http_server.cppindex 390d80b6..0f4b2055 100644--- a/src/http_server.cpp+++ b/src/http_server.cpp@@ -521,3 +521,7 @@ bool HttpServer::get_route(uint64_t hash, route_path** found_rpath) {return false;}++uint64_t HttpServer::node_state() const {+ return replication_state->node_state();+}diff --git a/src/raft_server.cpp b/src/raft_server.cppindex 7f5ed3a4..151bdc82 100644--- a/src/raft_server.cpp+++ b/src/raft_server.cpp@@ -360,14 +360,23 @@ bool ReplicationState::is_alive() const {braft::NodeStatus node_status;node->get_status(&node_status);- LOG(INFO) << "Status is: " << node_status.state;-return (node_status.state == braft::State::STATE_LEADER ||node_status.state == braft::State::STATE_TRANSFERRING ||node_status.state == braft::State::STATE_CANDIDATE ||node_status.state == braft::State::STATE_FOLLOWER);}+uint64_t ReplicationState::node_state() const {+ if(node == nullptr) {+ return 0;+ }++ braft::NodeStatus node_status;+ node->get_status(&node_status);++ return node_status.state;+}+void InitSnapshotClosure::Run() {// Auto delete this after Run()std::unique_ptr<InitSnapshotClosure> self_guard(this);