Update /ok to serve dual health check/benchmarking role
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
|
||||
#include "api_url_parser.hpp"
|
||||
#include "arena_allocator.hpp"
|
||||
#include "config.hpp"
|
||||
#include "connection.hpp"
|
||||
#include "connection_handler.hpp"
|
||||
#include "loop_iterations.hpp"
|
||||
#include "perfetto_categories.hpp"
|
||||
#include "pipeline_entry.hpp"
|
||||
#include "server.hpp"
|
||||
@@ -70,9 +70,9 @@ struct HttpConnectionState {
|
||||
* Supports the WeaselDB REST API endpoints with enum-based routing.
|
||||
*/
|
||||
struct HttpHandler : ConnectionHandler {
|
||||
HttpHandler()
|
||||
: banned_request_ids(
|
||||
ArenaStlAllocator<std::string_view>(&banned_request_arena)) {
|
||||
explicit HttpHandler(const weaseldb::Config &config)
|
||||
: config_(config), banned_request_ids(ArenaStlAllocator<std::string_view>(
|
||||
&banned_request_arena)) {
|
||||
// Stage 0: Sequence assignment thread
|
||||
sequenceThread = std::thread{[this]() {
|
||||
pthread_setname_np(pthread_self(), "txn-sequence");
|
||||
@@ -153,6 +153,9 @@ struct HttpHandler : ConnectionHandler {
|
||||
private:
|
||||
static constexpr int lg_size = 16;
|
||||
|
||||
// Configuration reference
|
||||
const weaseldb::Config &config_;
|
||||
|
||||
// Pipeline state (sequence thread only)
|
||||
int64_t next_version = 1; // Next version to assign (sequence thread only)
|
||||
|
||||
@@ -208,9 +211,10 @@ private:
|
||||
void handle_not_found(Connection &conn, const HttpConnectionState &state);
|
||||
|
||||
// HTTP utilities
|
||||
static void sendResponse(Connection &conn, int status_code,
|
||||
std::string_view content_type, std::string_view body,
|
||||
bool close_connection = false);
|
||||
static void send_response(Connection &conn, int status_code,
|
||||
std::string_view content_type,
|
||||
std::string_view body,
|
||||
bool close_connection = false);
|
||||
static void send_json_response(Connection &conn, int status_code,
|
||||
std::string_view json,
|
||||
bool close_connection = false);
|
||||
|
||||
Reference in New Issue
Block a user