How kourier-server/kourier works
Project type and purpose
• Kourier is an open-source, high-performance HTTP server library written in modern C++.
• It exposes two main building blocks for your applications: a blazing-fast HTTP server (HttpServer) and low-level socket classes (TcpSocket, TlsSocket).
• Its focus is on strict HTTP syntax compliance, minimal memory footprint, and maximal throughput.
File structure
• Top-level “Src” directory broken into four domains:
• Core – event loop, epoll integration, timers, signal-slot mechanism.
• Http – HTTP parser (state-machine + SIMD), request/router, HttpBroker, HttpServer and its options.
• Server – generic connection listener and worker abstractions, factories, repositories.
• Lib/Kourier – CMake install targets and packaging.
• Tests are organized under Src/Tests (unit specs, benchmark resources, Spectator test framework).
• Configuration & build: CMakeLists.txt, Config.cmake.in, Documentation folder.
Extract architecture notes from the README
• Layered design: Core underneath, Transport (TCP/TLS sockets) on top of Core, HTTP layer above transport, then Server orchestration.
• Key technologies: Linux epoll (edge-triggered), custom memory BIOs on OpenSSL, SIMD-accelerated HTTP parser, template-metaprogramming signal-slot.
• Patterns: event-driven/reactive, state machine for parsing, separation of concerns into modular libraries.
Main components and their interactions
a. Core Layer
• EpollEventNotifier / EpollEventSource: integrates Linux epoll into an AsyncQObject-based event loop.
• Timer, TimerPrivate_epoll: lightweight userspace timers.
• Signal-Slot machinery (AsyncQObject.h, MetaTypeSystem): dispatch events inside worker threads.
b. Transport Layer
• TcpSocket / TlsSocket classes: wrap POSIX sockets/Epoll integration; TlsContext & TlsConfiguration build custom BIOs for OpenSSL.
• IOChannel abstraction for buffered I/O.
c. HTTP Layer
• HttpRequestParser: byte-by-byte state-machine with SIMD acceleration.
• HttpBroker & HttpConnectionHandlerFactory: accept parsed requests, hand off to business logic via HttpRequestRouter.
• HttpServer / HttpServerWorker: listen for connections, spawn workers (based on ServerWorkerFactory).
d. Server Orchestration
• ConnectionListener (QTcpServerBasedConnectionListener & AsyncServerWorker): accept incoming sockets, register them in Core.
• ConnectionHandlerRepository & Factory: map raw sockets to HttpConnectionHandlers.
• Server – ties together listener, worker factories, error handling.
e. External Dependencies
• Linux kernel’s epoll interface.
• OpenSSL (custom memory BIOs).
• CMake build system.
• Spectator test framework for behavior specifications.
Architectural patterns & design principles
• Event-driven, reactive design with non-blocking I/O.
• Strict layering and separation of concerns.
• Factory & repository patterns for handler instantiation.
• State-machine and SIMD for parsing performance.
• Custom memory BIO pattern for TLS efficiency.