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

Handle premature termination of resource-limited request.

Kishore Nallanee3ed4271369
diff --git a/src/batched_indexer.cpp b/src/batched_indexer.cpp
index 97d1088d..ea23388a 100644
--- a/src/batched_indexer.cpp
+++ b/src/batched_indexer.cpp
@@ -205,17 +205,19 @@ void BatchedIndexer::run() {
std::string(magic_enum::enum_name(resource_check));
LOG(ERROR) << err_msg;
orig_res->set_422(err_msg);
+ orig_res->final = true;
async_req_res_t* async_req_res = new async_req_res_t(orig_req, orig_res, true);
server->get_message_dispatcher()->send_message(HttpServer::STREAM_RESPONSE_MESSAGE, async_req_res);
- break;
+ goto end;
}
else if(route_found) {
if(skip_writes && found_rpath->handler != post_config) {
orig_res->set(422, "Skipping write.");
+ orig_res->final = true;
async_req_res_t* async_req_res = new async_req_res_t(orig_req, orig_res, true);
server->get_message_dispatcher()->send_message(HttpServer::STREAM_RESPONSE_MESSAGE, async_req_res);
- break;
+ goto end;
}
async_res = found_rpath->async_res;
@@ -226,6 +228,7 @@ void BatchedIndexer::run() {
LOG(ERROR) << "Raw error: " << e.what();
// bad request gets a response immediately
orig_res->set_400("Bad request.");
+ orig_res->final = true;
async_res = false;
}
prev_body = orig_req->body;
@@ -240,10 +243,12 @@ void BatchedIndexer::run() {
}
if(!route_found) {
- break;
+ goto end;
}
}
+ end:
+
queued_writes--;
orig_req_res.next_chunk_index++;
iter->Next();
diff --git a/src/raft_server.cpp b/src/raft_server.cpp
index df0de966..1a1a45a5 100644
--- a/src/raft_server.cpp
+++ b/src/raft_server.cpp
@@ -202,6 +202,7 @@ void ReplicationState::write(const std::shared_ptr<http_req>& request, const std
if(config->get_skip_writes() && request->path_without_query != "/config") {
response->set_422("Skipping writes.");
+ response->final = true;
auto req_res = new async_req_res_t(request, response, true);
return message_dispatcher->send_message(HttpServer::STREAM_RESPONSE_MESSAGE, req_res);
}