$ show ptrd/kwik
Kwik is a pure Java implementation of the QUIC transport protocol (RFC 9000, RFC 9001, RFC 9369) supporting versions 1 and 2, along with extensions for unreliable datagrams (RFC 9221) and reliable stream reset. It provides both client and server APIs, with a modular architecture consisting of core protocol engine, CLI tool, HTTP/0.9 support, qlog structured logging, and interoperability test harness. The library is designed for embedding in Java applications needing low-latency, multiplexed, encrypted network connections. It includes a custom TLS 1.3 engine (agent15) for handshake management and leverages Java's module system. Extensive unit tests and interop testing against other QUIC implementations ensure protocol compliance. The codebase demonstrates strong engineering practices with clean abstractions (filter chains, builder patterns, null objects), though some features like server connection migration and stream priority remain incomplete.
The LLM identified 5 files worth highlighting for reuse:
A concurrency-safe rate limiter that executes a Runnable at most once per key, using ConcurrentHashMap and a sentinel marker. Cleanly implements a one-shot rate limiting pattern that can be reused in any Java application requiring per-key throttle or debounce behavior. The class is self-contained with no internal dependencies beyond standard Java libraries.
An immutable interval class supporting inclusive ranges with merge and subtract operations. Provides efficient handling of integer ranges (e.g., for ACK frame generation) and can be reused in any project requiring interval arithmetic. The implementation is clean, well-tested, and has no external dependencies.
Implements QUIC's variable-length integer encoding (1-8 bytes with 2-bit length prefix) for both ByteBuffer and InputStream. While specific to QUIC, the encoding pattern is reusable for any protocol needing compact integer representation. The class is self-contained, handles edge cases, and includes thorough parsing/serialization methods.
A controllable clock implementation for deterministic time management in unit tests. Supports setting the current time, advancing time, and registering listeners for time changes. This pattern is universally reusable for testing time-sensitive logic without relying on system clock or thread sleeps. Self-contained with no internal dependencies.
A reflection-based utility to set private fields on objects, bypassing access checks. Includes support for static fields and allows access to final fields by resetting the modifier. While specific to testing, this utility is widely applicable for injecting test dependencies or manipulating state in legacy code. Self-contained and handles Java module system limitations.