Skip to content

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

Use http lib timestamp separately as conn_ts.

Kishore Nallanaec1e6cff06f
diff --git a/include/http_data.h b/include/http_data.h
index 29d9bd2e..4c5dc14c 100644
--- a/include/http_data.h
+++ b/include/http_data.h
@@ -232,6 +232,9 @@ struct http_req {
uint64_t start_ts;
+ // timestamp from the underlying http library
+ uint64_t conn_ts;
+
std::mutex mcv;
std::condition_variable cv;
bool ready;
@@ -250,6 +253,8 @@ struct http_req {
start_ts = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
+ conn_ts = start_ts;
+
}
http_req(h2o_req_t* _req, const std::string & http_method, const std::string & path_without_query, uint64_t route_hash,
@@ -263,12 +268,15 @@ struct http_req {
if(_req != nullptr) {
const auto& tv = _req->processed_at.at;
- start_ts = (tv.tv_sec * 1000 * 1000) + tv.tv_usec;
+ conn_ts = (tv.tv_sec * 1000 * 1000) + tv.tv_usec;
is_http_v1 = (_req->version < 0x200);
} else {
- start_ts = std::chrono::duration_cast<std::chrono::microseconds>(
- std::chrono::system_clock::now().time_since_epoch()).count();
+ conn_ts = std::chrono::duration_cast<std::chrono::microseconds>(
+ std::chrono::system_clock::now().time_since_epoch()).count();
}
+
+ start_ts = std::chrono::duration_cast<std::chrono::microseconds>(
+ std::chrono::system_clock::now().time_since_epoch()).count();
}
~http_req() {
diff --git a/src/core_api.cpp b/src/core_api.cpp
index c2facf97..6e76e97b 100644
--- a/src/core_api.cpp
+++ b/src/core_api.cpp
@@ -377,7 +377,7 @@ bool get_search(const std::shared_ptr<http_req>& req, const std::shared_ptr<http
std::string results_json_str;
Option<bool> search_op = CollectionManager::do_search(req->params, req->embedded_params_vec[0],
- results_json_str, req->start_ts);
+ results_json_str, req->conn_ts);
if(!search_op.ok()) {
res->set(search_op.code(), search_op.error());
@@ -525,7 +525,7 @@ bool post_multi_search(const std::shared_ptr<http_req>& req, const std::shared_p
std::string results_json_str;
Option<bool> search_op = CollectionManager::do_search(req->params, req->embedded_params_vec[i],
- results_json_str, req->start_ts);
+ results_json_str, req->conn_ts);
if(search_op.ok()) {
response["results"].push_back(nlohmann::json::parse(results_json_str));