This is an automated email from the ASF dual-hosted git repository.
apratim pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-resilientdb-graphql.git
The following commit(s) were added to refs/heads/main by this push:
new 710bc8d Updated Crow Timeout
710bc8d is described below
commit 710bc8d5868e803b031f2632aa80558f307e21ff
Author: Apratim Shukla <[email protected]>
AuthorDate: Thu Jan 11 13:57:04 2024 -0800
Updated Crow Timeout
---
docs/doxygen/Doxyfile | 6 ++--
docs/doxygen/doxygen_html_style.css | 4 +++
docs/doxygen/logo.png | Bin 7228 -> 71672 bytes
service/http_server/crow_service.cpp | 54 +++++++++++++++++++++++------------
service/http_server/crow_service.h | 2 ++
5 files changed, 44 insertions(+), 22 deletions(-)
diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile
index 2a07fcb..e902499 100644
--- a/docs/doxygen/Doxyfile
+++ b/docs/doxygen/Doxyfile
@@ -42,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
- PROJECT_NAME = NexRes SDK
+ PROJECT_NAME = ResilientDB SDK
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
This
# could be handy for archiving the generated documentation or if some version
@@ -54,7 +54,7 @@ DOXYFILE_ENCODING = UTF-8
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
- PROJECT_BRIEF = "NexRes SDK"
+ PROJECT_BRIEF = "ResilientDB SDK"
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
@@ -1370,7 +1370,7 @@ HTML_STYLESHEET =
# documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
-HTML_EXTRA_STYLESHEET =
+HTML_EXTRA_STYLESHEET = doxygen_html_style.css
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
diff --git a/docs/doxygen/doxygen_html_style.css
b/docs/doxygen/doxygen_html_style.css
new file mode 100644
index 0000000..b4d993b
--- /dev/null
+++ b/docs/doxygen/doxygen_html_style.css
@@ -0,0 +1,4 @@
+img[src="logo.png"]{
+ width: 250px;
+ height: 83px;
+}
diff --git a/docs/doxygen/logo.png b/docs/doxygen/logo.png
index 2568a4a..b9509d2 100644
Binary files a/docs/doxygen/logo.png and b/docs/doxygen/logo.png differ
diff --git a/service/http_server/crow_service.cpp
b/service/http_server/crow_service.cpp
index ca9e8a4..d7c3976 100644
--- a/service/http_server/crow_service.cpp
+++ b/service/http_server/crow_service.cpp
@@ -48,7 +48,9 @@ namespace sdk {
CrowService::CrowService(ResDBConfig client_config, ResDBConfig server_config,
uint16_t port_num)
: client_config_(client_config), server_config_(server_config),
port_num_(port_num),
- kv_client_(client_config_), txn_client_(server_config_) {}
+ kv_client_(client_config_), txn_client_(server_config_) {
+ GetAllBlocks(100, true, false);
+}
void CrowService::run() {
crow::SimpleApp app;
@@ -59,24 +61,38 @@ void CrowService::run() {
// Get all values
CROW_ROUTE(app, "/v1/transactions")
([this](const crow::request &req, response &res) {
- auto values = kv_client_.GetAllValues();
- if (values != nullptr) {
- LOG(INFO) << "client getallvalues value = " << values->c_str();
+ uint64_t cur_time = std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now().time_since_epoch()
+ ).count();
- // Send updated blocks list to websocket
- if (users.size() > 0) {
- for (auto u : users)
- u->send_text("Update blocks");
- }
+ if (cur_time < last_db_scan_time + DB_SCAN_TIMEOUT_MS) {
+ res.code = 503;
+ res.set_header("Content-Type", "text/plain");
+ res.end("Get all transactions functionality on cooldown (" +
+ std::to_string(last_db_scan_time + DB_SCAN_TIMEOUT_MS - cur_time) +
+ " ms left)");
+ } else {
+ last_db_scan_time = cur_time;
- num_transactions_++;
+ auto values = kv_client_.GetAllValues();
+ if (values != nullptr) {
+ LOG(INFO) << "client getallvalues value = " << values->c_str();
- res.set_header("Content-Type", "application/json");
- res.end(std::string(values->c_str()));
- } else {
- res.code = 500;
- res.set_header("Content-Type", "text/plain");
- res.end("getallvalues fail");
+ // Send updated blocks list to websocket
+ if (users.size() > 0) {
+ for (auto u : users)
+ u->send_text("Update blocks");
+ }
+
+ num_transactions_++;
+
+ res.set_header("Content-Type", "application/json");
+ res.end(std::string(values->c_str()));
+ } else {
+ res.code = 500;
+ res.set_header("Content-Type", "text/plain");
+ res.end("getallvalues fail");
+ }
}
});
@@ -181,7 +197,7 @@ void CrowService::run() {
// Retrieve blocks in batches of size of the int parameter
CROW_ROUTE(app, "/v1/blocks/<int>")
([this](const crow::request &req, response &res, int batch_size) {
- auto values = GetAllBlocks(batch_size, true);
+ auto values = GetAllBlocks(batch_size, false, true);
if (values == "") {
res.code = 500;
res.set_header("Content-Type", "text/plain");
@@ -343,11 +359,11 @@ void CrowService::run() {
+ ", \"minDataReceiveNum\" : " +
std::to_string(min_data_receive_num)
+ ", \"maxMaliciousReplicaNum\" : " +
std::to_string(max_malicious_replica_num)
+ ", \"checkpointWaterMark\" : " +
std::to_string(checkpoint_water_mark)
- + ", \"transactionNum\" : " +
std::to_string(num_transactions_)
+ + ", \"transactionNum\" : " +
std::to_string(num_transactions_)
+ ", \"blockNum\" : " + std::to_string(*block_num_resp)
+ ", \"chainAge\" : " + std::to_string(chain_age)
+ "}]");
- LOG(INFO) << std::string(values.c_str());
+ LOG(INFO) << std::string(values.c_str());
res.set_header("Content-Type", "application/json");
res.end(std::string(values.c_str()));
});
diff --git a/service/http_server/crow_service.h
b/service/http_server/crow_service.h
index 2c35df6..9843808 100644
--- a/service/http_server/crow_service.h
+++ b/service/http_server/crow_service.h
@@ -51,6 +51,8 @@ private:
std::unordered_set<crow::websocket::connection *> users;
std::atomic_uint16_t num_transactions_ = 0;
std::atomic_uint64_t first_commit_time_ = 0;
+ uint64_t last_db_scan_time = 0;
+ const uint64_t DB_SCAN_TIMEOUT_MS = 30000;
};
} // namespace sdk