HTTP Server¶
Namespace: dftracer::utils::server
-
struct HttpRequest¶
Public Functions
-
int parse(const char *buf, std::size_t len)¶
Parse from receive buffer. Returns bytes consumed on success, -1 on error, -2 if incomplete.
-
std::string_view header(std::string_view name) const¶
Find a header value by name (case-insensitive).
-
bool has_header(std::string_view name, std::string_view value) const¶
Check if header matches value (case-insensitive).
-
int parse(const char *buf, std::size_t len)¶
-
struct HttpResponse¶
Public Types
-
using StreamGenerator = coro::AsyncGenerator<StreamChunk>¶
Public Functions
-
inline bool is_streaming() const¶
-
std::string serialize_headers() const¶
Serialize HTTP response headers to string (CRLF-terminated). Automatically adds Content-Length if body is non-empty and not already set.
-
std::string serialize() const¶
Full response (headers + body).
Public Members
-
int status_code = 200¶
-
std::string status_text = "OK"¶
-
std::vector<std::pair<std::string, std::string>> headers¶
-
std::string body¶
-
std::unique_ptr<StreamGenerator> stream¶
Public Static Functions
-
static HttpResponse ok()¶
-
static HttpResponse ok(const std::string &body, const std::string &content_type = "application/json")¶
-
static HttpResponse not_found()¶
-
static HttpResponse bad_request(const std::string &msg)¶
-
static HttpResponse internal_error(const std::string &msg)¶
-
static HttpResponse streaming(std::unique_ptr<StreamGenerator> gen, const std::string &content_type = "application/x-ndjson")¶
-
using StreamGenerator = coro::AsyncGenerator<StreamChunk>¶
-
struct QueryCursor¶
Cursor for paginated trace queries. Encodes the current position in the scan across files and chunks for efficient resumption.
Public Functions
-
std::string encode() const¶
Base64-encode the cursor for URL-safe transmission.
Public Members
-
std::size_t file_index = 0¶
-
std::uint32_t chunk_index = 0¶
-
std::uint32_t line_offset = 0¶
Public Static Functions
-
static std::optional<QueryCursor> decode(std::string_view cursor)¶
Decode a cursor from a Base64 string.
-
std::string encode() const¶
-
class QueryParams¶
Simple URL query parameter map.
Public Functions
-
std::string_view get(std::string_view key, std::string_view default_value = {}) const¶
-
bool has(std::string_view key) const¶
-
int get_int(std::string_view key, int default_value = 0) const¶
-
double get_double(std::string_view key, double default_value = 0) const¶
Public Static Functions
-
static QueryParams parse(std::string_view query)¶
Parse from a query string (“key=value&key2=value2”).
-
std::string_view get(std::string_view key, std::string_view default_value = {}) const¶
-
class Router¶
Simple prefix-based HTTP router.
Public Functions
-
void get(const std::string &path, RouteHandler handler)¶
-
void post(const std::string &path, RouteHandler handler)¶
-
coro::CoroTask<HttpResponse> handle(const HttpRequest &req)¶
Match request method + path, parse query params, invoke handler. Returns 404 if no route matches.
-
void get(const std::string &path, RouteHandler handler)¶
-
class TcpListener¶
TCP listener that accepts connections and spawns per-connection coroutine handlers using structured concurrency.
Public Types
Public Functions
-
TcpListener(const std::string &addr, uint16_t port)¶
-
~TcpListener()¶
-
TcpListener(const TcpListener&) = delete¶
-
TcpListener &operator=(const TcpListener&) = delete¶
-
bool start(int backlog = 128)¶
Bind and listen. Returns true on success.
-
coro::CoroTask<void> accept_loop(CoroScope &scope, ConnectionHandler handler)¶
-
void stop()¶
Request graceful shutdown. The accept loop will break on the next iteration. In-flight handlers drain via CoroScope.
-
inline int fd() const¶
-
inline uint16_t port() const¶
-
TcpListener(const std::string &addr, uint16_t port)¶
-
class TraceIndex¶
Scans a directory for trace files and caches paths to their root-local
.dftindexdatabase. Used by API handlers to resolve file paths and check index availability.Public Types
-
using BloomCache = dftracer::utils::utilities::composites::dft::indexing::BloomFilterCache¶
Public Functions
-
TraceIndex(const std::string &directory, const std::string &index_dir, std::size_t max_concurrent = 8)¶
-
inline std::size_t file_count() const¶
-
const FileInfo *find_file(const std::string &path) const¶
Find a file by its path. Returns nullptr if not found.
-
const FileInfo *file_at(std::size_t index) const¶
Find a file by index. Returns nullptr if out of range.
-
inline const std::string &directory() const¶
-
inline const std::string &index_dir() const¶
-
inline std::size_t max_concurrent() const¶
-
inline BloomCache &bloom_cache()¶
-
inline std::uint64_t global_min_timestamp_us() const¶
-
inline std::uint64_t global_max_timestamp_us() const¶
-
struct FileInfo¶
Public Members
-
std::string path¶
-
std::string index_path¶
-
bool has_bloom_data = false¶
-
bool has_checkpoint_index = false¶
-
std::uint64_t min_timestamp_us = 0¶
-
std::uint64_t max_timestamp_us = 0¶
-
std::uint64_t compressed_size = 0¶
-
std::uint64_t uncompressed_size = 0¶
-
std::size_t num_checkpoints = 0¶
-
std::uint64_t checkpoint_size = 0¶
-
std::uint64_t num_lines = 0¶
-
double size_mb = 0¶
-
std::string path¶
-
using BloomCache = dftracer::utils::utilities::composites::dft::indexing::BloomFilterCache¶
-
struct Header¶
-
struct ParsedRequest¶