$ show facebook/proxygen
Proxygen is a production-grade C++ HTTP library developed by Meta, providing comprehensive support for HTTP/1.1, HTTP/2, HTTP/3 (QUIC), and WebTransport. It offers both a classic callback-based server/client framework and a modern coroutine-based API using folly::coro. The architecture is layered: low-level codecs for wire protocol parsing, session management with flow control and rate limiting, transport abstraction (TCP, TLS, QUIC), and high-level handler/filter chains. The library includes extensive utilities for DNS resolution, consistent hashing, stream compression, structured headers, and connection pooling. It is heavily tested and designed for high-performance, multi-threaded production environments. While primarily a server framework, it also provides a full client stack and sample applications (echo, proxy, push, WebSocket, H3). The codebase is well-structured with many reusable components, though it remains tightly coupled to Meta's ecosystem (folly, wangle, fizz, mvfst).
The LLM identified 7 files worth highlighting for reuse:
Implements weighted Rendezvous Hashing (highest random weight) for consistent node selection. The algorithm is self-contained, requires only standard containers and folly::Hash, and provides O(n) selection with low memory overhead. Can be extracted and reused in any project needing distributed key assignment with minimal reshuffling on node/weight changes.
Provides functions to normalize and validate file paths, preventing directory traversal attacks (e.g., path canonicalization, null-byte detection, allowlist enforcement). The implementation is purely algorithmic and depends only on the standard filesystem library and string utilities. Easily extractable for any application requiring safe path handling.
A template-based perfect hash map for known HTTP header codes, offering O(1) lookup with optional case-insensitivity and duplicate key support. It generates a lookup table at compile time using a manually crafted perfect hash function. The component is self-contained (no internal proxygen dependencies) and can be reused for any enum-to-value mapping where the set of keys is known at compile time.
A generic, type-safe two-way filter chain template (similar to the chain-of-responsibility pattern) that allows interleaving callbacks between a source and a sink. It is fully templated and depends only on standard C++. Can be extracted and applied to any scenario requiring a composable pipeline of interceptors (e.g., logging, rate limiting, transformation) without coupling to proxigen's HTTP types.
Provides an awaitable baton that supports timeout and cancellation, built on folly::coro::Baton and folly::HHWheelTimer. The implementation is clean and self-contained, relying only on folly. It can be extracted for any coroutine-based project that needs a single-shot synchronization primitive with timeout semantics.
Contains the Huffman encoding and decoding tables and logic used for HPACK/QPACK header compression. The Huffman tree is precomputed in a static lookup table, and the encode/decode functions are pure functions with no external dependencies other than basic types. This component can be extracted for any project needing Huffman coding for a fixed alphabet (e.g., custom protocol framing).
Implements a bucketized timeout set for efficient management of many timers with the same timeout interval. It uses folly::HHWheelTimer internally but provides a simpler interface. The component is self-contained (only depends on folly) and can be reused in any event-driven application that needs to track many identical-interval timeouts without per-timer overhead.