Always use struct

This commit is contained in:
2025-08-23 06:10:55 -04:00
parent b86cf3680e
commit 4af5e0423e
14 changed files with 56 additions and 41 deletions

View File

@@ -1,14 +1,16 @@
#pragma once
#include <memory>
#include <string_view>
#include <thread>
#include <llhttp.h>
#include "connection.hpp"
#include "connection_handler.hpp"
#include "perfetto_categories.hpp"
#include "server.hpp"
#include "thread_pipeline.hpp"
#include <llhttp.h>
#include <memory>
#include <string_view>
#include <thread>
/**
* HTTP routes supported by WeaselDB server.
@@ -60,14 +62,7 @@ struct HttpConnectionState {
* HTTP/1.1 server implementation using llhttp for parsing.
* Supports the WeaselDB REST API endpoints with enum-based routing.
*/
class HttpHandler : public ConnectionHandler {
static constexpr int kFinalStageThreads = 2;
static constexpr int kLogSize = 12;
ThreadPipeline<std::unique_ptr<Connection>> pipeline{kLogSize,
{kFinalStageThreads}};
std::vector<std::thread> finalStageThreads;
public:
struct HttpHandler : ConnectionHandler {
HttpHandler() {
for (int threadId = 0; threadId < kFinalStageThreads; ++threadId) {
finalStageThreads.emplace_back([this, threadId]() {
@@ -124,6 +119,12 @@ public:
static int onMessageComplete(llhttp_t *parser);
private:
static constexpr int kFinalStageThreads = 2;
static constexpr int kLogSize = 12;
ThreadPipeline<std::unique_ptr<Connection>> pipeline{kLogSize,
{kFinalStageThreads}};
std::vector<std::thread> finalStageThreads;
// Route handlers
void handleGetVersion(Connection &conn, const HttpConnectionState &state);
void handlePostCommit(Connection &conn, const HttpConnectionState &state);