You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Complete inventory of what ships in flare/, generated
by walking flare/__init__.mojo plus each
submodule. Every entry here is part of the stable public surface
(see Stability). Internal types (anything in _*.mojo)
are intentionally excluded.
For runnable code, cookbook.md maps "I want to..." to
an example file. For layering and the request lifecycle, see
architecture.md.
HttpServer.bind(addr) / serve(handler) / serve(handler, num_workers=N) — version-aware listener that dispatches HTTP/1.1, HTTP/2 over TLS (ALPN), and h2c (RFC 9113 §3.4 preface peek, no Upgrade dance) to the same handler
HttpServer.bind_many(addrs: List[SocketAddr]) — single-worker listener over multiple distinct addresses; the accept loop walks every fd and demuxes onto the same handler
HTTP/1.1 trailer fields (RFC 7230 §4.1.2 / §4.4) — StreamingResponse[B].trailers: HeaderMap on the outbound side (buffered Response uses Content-Length and never carries trailers), automatic Trailer: header, smuggling guard rejects trailers when Content-Length is present or when forbidden trailer names are listed; HttpClient parses inbound trailers off the chunked decoder and lands them on Response.trailers (also a HeaderMap)
HttpServer.serve_static(StaticResponse) — pre-encoded static-response fast path that skips parsing and handler dispatch (used by flare_mc_static bench row)
HttpClient(base_url, auth=...), HttpClient(prefer_h2c=True) — version-aware over TLS+ALPN; prefer_h2c=True opts into HTTP/2 cleartext via prior knowledge
HttpClient.with_pool(...) — connection pool keyed on (scheme, host, port), idle reuse, per-origin caps, stale-conn retry. Covers cleartext HTTP/1.1 and, over TLS, a TlsConnectionPool for HTTPS keep-alive (the whole established TlsStream is pooled); idle_count() / tls_idle_count() expose pool depth
HttpClient(h2c_upgrade=True) — h2c via Upgrade (RFC 7540 §3.2): client emits Upgrade: h2c + HTTP2-Settings on the first request, reads 101, carries the peer SETTINGS forward into a fresh h2 connection
HttpClient(prefer_http3=True) / .with_prefer_http3() — HTTP/3 over QUIC: per-origin Alt-Svc (RFC 7838) discovery + cache, happy-eyeballs race of the HTTP/3-vs-HTTP/2 connection establishment on first contact (the request is sent once on the winner, never duplicated), transparent fallback to HTTP/2/HTTP/1.1 on any QUIC failure. Idempotent requests may ride 0-RTT on a resumed connection (replaying at 1-RTT if the server rejects). HTTP/3 connections are pooled + multiplexed per origin
auto_decompress=True (default) — transparent response body decompression (gzip / deflate / brotli) driven by Content-Encoding, bounded by a 16 MiB decompressed-size cap (zip-bomb guard) tunable via .with_max_decompressed_bytes(n)
HttpClient.send_chunked(method, url, source) — streaming request upload from a ChunkSource via chunked transfer-encoding (one chunk in flight, body never materialized)
HttpClient.get_streaming(url) -> HttpDownload — streaming download: parses the response head, then read_chunk() pulls the body in bounded memory (Content-Length / chunked / close-delimited decoded on the fly)
.with_proxy(url) + HTTP_PROXY / HTTPS_PROXY / NO_PROXY / ALL_PROXY env — routes requests through an HTTP proxy via a CONNECT tunnel (both http:// and https://; TLS runs over the tunnel via TlsStream.connect_over_tcp)
Application-scoped state via captured handlers — wrap your handler in a struct that holds shared state by value; for shared mutation, use a flare.runtime.Pool heap-address handle
Reflects on a struct's fields, runs every extractor before serve; malformed input becomes a sanitised 400. Copies a registration-time prototype per request, so pre-set fields survive
No-op extractor field carrying registration-time state (DB pool, config, cache) alongside request-derived extractors -- the analogue of axum's State(db). Set it on a prototype H, then Extracted[H](proto^)
Custom types are handled by writing your own Extractor struct
that pulls and validates the value from the request. The
extractor surface is intentionally concrete — every type is
named — so the IDE, the compiler, and the reader all see the
same shape.
Middleware
Each layer is itself a Handler that holds another Handler. Stack
by nesting structs:
Layer
Behaviour
Where
Logger[Inner]
Space-delimited per-request line ([flare] GET /users 200 12ms)
Re-invoke the inner handler up to max_attempts times on 5xx; RFC 9110 §9.2.2 idempotent-method gate on by default (GET / HEAD / PUT / DELETE / OPTIONS retry; POST / PATCH pass through once unless retry_only_idempotent is False). Optional exponential backoff with jitter via RetryPolicy(backoff_base_ms, backoff_max_ms, backoff_jitter_ms)
Post-hoc wall-clock guard: invokes the inner handler synchronously, then if the elapsed time exceeds budget_ms, replaces the response with a sanitised 504. Does not cancel the inner handler mid-execution -- it only refuses the response that was produced too late. budget_ms <= 0 is the explicit "disabled" sentinel that always trips 504. The cancel-cell wiring that would let the deadline preempt the inner handler is a future addition.
Token-bucket admission gate: admits rate_per_sec req/s with a burst depth, rejects with 429 Too Many Requests once the bucket is empty (inner handler never invoked on rejection). rate_per_sec <= 0 disables it
Opens after failure_threshold consecutive failures (5xx or raise), fast-fails with 503 for cooldown_ms, then a half-open probe; success closes it. failure_threshold <= 0 disables it
RFC 9110 §12.5.3 q-value parser exposed for direct use
flare.http.middleware
HTTP caching (RFC 9111)
Cache primitives, an in-memory store, and a wrapping Cache[Inner, S]
middleware that handles RFC 9111 freshness and conditional revalidation.
Surface
Where
Cache[Inner, S] — wrapping middleware: on cache hit + fresh-per-RFC-9111 entry, returns the stored response without invoking Inner; on miss / stale, runs Inner and stores the response (subject to Cache-Control directives). Conditional revalidation forwards If-None-Match / If-Modified-Since to upstream and folds 304 into the cached entry
CacheStore trait + InMemoryCacheStore(capacity) — bounded FIFO store with get / put / remove; freshness logic lives on CacheEntry (parsed CacheControl + Vary carried at insert time so the lookup path doesn't re-parse)
flare.http.cache.store
CacheEntry.is_fresh(now_ms) — RFC 9111 §4.2 freshness check against the entry's parsed directives and Date: baseline
stream_response[S: ChunkSource](source, status) — wire-agnostic streaming from the normal Handler.serve -> Response contract: the returned Response.body_stream is pulled per writable edge and framed as H1 chunked, H2 DATA, H3 DATA, or chunked-over-SSL_write (https). The same handler streams byte-identically on every wire (proven by tests/http/test_cross_wire_streaming.mojo); the H1 head is framed by the shared frame_h1_stream_head_into adapter
flare.http.response, flare.http._server.write
response_from_body[B: Body](body, status, reason) — opt-in Response[B] ergonomics: lowers any Body impl into the concrete Response (buffered when length-known, body_stream-chunked otherwise) for the normal Handler path, no hot-path change
flare.http.response
RequestView[origin], parse_request_view — zero-copy borrow over the parsed request, paired with ViewHandler
Askama-shape templates: {{ name }} (HTML-escaped, `
safeopt-out),{% if %}...{% endif %}, {% for x in name %}...{% endfor %}, single-level inheritance via {% block %}...{% endblock %}+{% extends "" %}(rendered viaTemplate.render_extending(ctx, parent)), TemplateError`
ByteRange, parse_range, FileServer (see Middleware)
flare.http.fs
Streaming proxy surface (v0.9)
The shape a streaming proxy (any reverse proxy that pumps an external
producer's output to a client) needs: a typed streaming server whose
response body's chunks arrive on a reactor-registered fd, with
backpressure coupled across upstream and downstream. The front is
a StreamHandler plus a typed state struct — no raw reactor loop, no
UnsafePointer state smuggling, no per-slot alloc tables, no manual
byte parsing, and — for the common single-upstream relay — no file
descriptors, no byte Span wrapping, and no per-connection table in
front code at all. See
streaming_proxy.mojo for
the end-to-end shape; a complete relay front is on_open (attach a
source) + on_upstream (conn.relay_upstream()).
Surface
Where
StreamHandler — typed lifecycle trait (on_open / on_upstream / on_writable / on_close); the handler struct's fields are its shared state
flare.http.streaming_server, flare
StreamConn — framework-owned per-connection handle: owns the client TcpStream, a per-connection Cancel, one optional framework-owned upstream source, and a single coalescing outbound buffer (send queues; the reactor drains on writable edges)
flare.http.streaming_server, flare
HttpServer.serve_streaming[H](handler, max_in_flight=0, retry_after_s=1) — the streaming entry point; max_in_flight admits with a 503 + Retry-After past the cap. A serve_streaming[H](handler, num_workers=N) overload fans out across N pthreads (StreamFrontend + shared reactor loop), each worker with its own handler copy
conn.attach_upstream(source) + conn.relay_upstream() — hand an UpstreamChunkSource to the framework (it watches the fd, owns the source, closes it on teardown, and cancels upstream on client disconnect); relay_upstream is the whole drain loop. No descriptors, no table, no manual close
flare.http.streaming_server
conn.send(data) — accepts Span[UInt8, _] (zero-copy), List[UInt8], or a StringSlice/string; a front sends bytes or text with no Span[UInt8, _] wrap at the call site
flare.http.streaming_server
conn.attach_upstream(fd) / detach_upstream() (low-level) — register a raw front-owned upstream fd (a bare pipe / eventfd, not an UpstreamChunkSource) so the reactor fires on_upstream; the front then owns the fd's close
flare.http.streaming_server
AsyncChunkSource trait + ChunkPoll tri-state (ready(bytes) / pending(fd) / eof()) — a body whose chunks arrive asynchronously without busy-polling
flare.http.async_body, flare
UpstreamChunkSource — concrete AsyncChunkSource over a framed UDS logical stream; UpstreamChunkSource.connect(path) dials it in one call (request_id defaults to 1); poll(cancel) returns the tri-state, send_cancel() propagates a client disconnect upstream
flare.http.async_body, flare
Watermark backpressure: conn.set_watermarks(hi, lo), write_buffer_full(), apply_backpressure() — hi/lo hysteresis gates upstream read interest so a slow client cannot force unbounded buffering
flare.http.streaming_server
Incremental inbound body: conn.enable_inbound(), conn.read_body(max_bytes) returning ChunkPoll — bounded-memory consumption of a large request body
flare.http.streaming_server
Write coalescing: K send calls in one tick flush in one send(2); conn.write_syscalls() observes it
flare.http.streaming_server
FrameMux — multiplexes many logical streams over one owned UnixStream (open / send_chunk / done / cancel / flush / pump / poll); frame | u32 len | u64 request_id | u8 kind | payload | via encode_frame / decode_frame, Frame, FrameKind, FrameDemux; fuzz-clean
StructuredLogger[Inner] — JSON-per-line additive sibling: {"ts","method","url","status","latency_ms","request_id","peer"}; works with Datadog / Elastic / Loki / Splunk / CloudWatch out of the box
flare.http.structured_logger
Metrics[Inner] — Prometheus text-exposition middleware; emits flare_http_requests_total{method,status}, flare_http_request_duration_seconds_bucket{le}, ..._sum, ..._count, flare_http_requests_in_flight, flare_http_request_errors_total with the canonical Prometheus default-bucket layout
flare.http.metrics
HTTP/2
HttpServer and HttpClient are HTTP-version-aware: the reactor
auto-dispatches HTTP/1.1, HTTP/2 over TLS+ALPN, and h2c per RFC 9113
§3.4 to the same handler. The low-level codec / state-machine
primitives in flare.http2 are public for callers who want their
own dispatch loop.
HPACK Huffman codec — scalar-correct, H=1 wire-up + RFC 7541 §C.4 fixtures, and a 256-entry table-driven fast decoder that resolves codes of length <= 8 in one lookup (>=3x scalar across 16 B / 256 B / 4 KB / 64 KB input sizes; codes of length 9..30 fall through to the scalar bit-walker)
RFC 8441 Extended CONNECT (server side — reactor sidecar dispatch): edge-driven WsH2Handler (on_open/on_message/on_close) + HttpServer.serve[H: Handler, W: WsH2Handler](handler, ws_handler) route a live CONNECT stream to the handler over the unified reactor (boxed WsH2Hooks, zero-cost when no ws_handler); forked h2c e2e
HTTP/2 concurrent multiplexed server streaming (K1): a handler returning stream_response / stream_sse_response ships DATA frames per writable edge; many streaming responses run concurrently on one connection with a fair per-stream pump, min(conn, stream) send-window bounding, and WINDOW_UPDATE re-pump (no single-active-stream ceiling); trailers close each stream — the same body-stream path as H1 chunked
End-to-end QUIC v1 (RFC 9000) + HTTP/3 (RFC 9114) server: the
sans-I/O codecs, the pure state machines, the OpenSSL AEAD
backend behind QuicCrypto, the rustls binding behind
RustlsQuicAcceptor, the QUIC UDP reactor (live
recv -> dispatch -> handle -> drain -> protect -> sendto
cycle), the per-stream HTTP/3 dispatch
(Http3Connection slab on QuicListener), the
Handler-mounted serve loop (HttpServer.bind_with_http3 + serve_http3[H]), and the ALPN router on top of
HttpServer.bind are all wired. The same Handler instance
reaches HTTP/1.1 + h2c + HTTP/2 + HTTP/3 simultaneously.
Live wire status (gate met). The QUIC reactor I/O cycle is
live, the rustls FFI wrapper surfaces the per-level
KeyChange Handshake / 1-RTT keys back to
QuicConnection.install_handshake_keys /
install_1rtt_keys, and the Handler dispatch chain carries
requests end-to-end over the wire. The bench gate
(flare_h3 >= 72,571 req/s vs quiche) closed: flare HTTP/3 leads
at 74,653 req/s (median, +2.9 % over quiche 0.22) on the
1-client x 100-stream workload. The win came from the reactor
rewrite -- eliminating per-packet whole-connection deep copies
(in-place ref mutation), a cached-table QPACK decode path,
and coalesced 1-RTT egress with capacity-reserved packet
builders. See the docs/benchmark.md HTTP/3 row for the full
table and baselines.
The codec layer is byte-clean and covered by fuzz-quic-varint,
fuzz-quic-long-header, fuzz-quic-frame-decode,
fuzz-quic-transport-params, fuzz-h3-frame,
fuzz-qpack-decode, fuzz-quic-packet-decrypt,
fuzz-quic-initial-handshake, fuzz-quic-connection-id, and
fuzz-h3-server (200 K runs each, zero crashes); see the
fuzz coverage table. The codec
demo at quic_codec_demo.mojo
exercises varint, frame codec, transport parameters, state
machine, and congestion controller round-trips end-to-end. The
runnable server example at http3_server.mojo
serves a single Handler over HTTP/1.1 + HTTP/2 + HTTP/3 simultaneously.
QUIC congestion control (RFC 9002 §7): the CongestionController trait + RenoController (RFC 9002 NewReno) + CubicController (RFC 9438 CUBIC with RFC 9406 HyStart++ slow-start exit), selected by CcChoice. The 1-RTT loss-recovery path (flare.quic._loss_recovery) now runs an RTT estimator (RFC 9002 §5), ACK-based loss detection (§6.1 packet-number + time thresholds), the §6.2 PTO formula, and drives a CUBIC controller on every ACK / loss. RFC 9002 §7.7 send pacing is not yet wired (the window gates burst size; no inter-packet timer) -- tracked v0.9.x follow-up
Batched UDP I/O (flare.udp.batch, Linux): BatchReceiver (one recvmmsg(2) drains a whole inbound burst), send_batch (one sendmmsg(2) for a vector of datagrams), send_segmented (GSO UDP_SEGMENT one-sendmsg egress), all behind udp_batch_supported() + an ENOSYS-latched fallback to per-datagram recvfrom / sendto. The QUIC reactor's per-tick drain uses BatchReceiver by default (disable with FLARE_QUIC_NO_BATCH=1); loopback A/B shows no throughput regression on the single-client HTTP/3 bench and tighter run-to-run variance
flare.udp.batch
QUIC server reactor: QuicServerConfig, QuicListener, QuicConnection, ConnectionIdTable (RFC 9000 §5 -- multiple connection IDs per peer). UDP bind + a blocking recv_from wake followed by a batched recvmmsg burst drain (per-datagram try_recv_from fallback) + per-datagram dispatch with coalesced 1-RTT egress, ECN echo per RFC 9002 §A.4. Idle-timeout dispatch is wired today, plus stateless reset on unknown short-header DCIDs (RFC 9000 §10.3) and structural PTO / ack-delay timer dispatch that re-flushes 1-RTT egress; full server-side loss-driven retransmit and send pacing are tracked v0.9.x follow-ups; fuzz-covered (fuzz-quic-initial-handshake, fuzz-quic-connection-id)
flare.quic.server
HTTP/3 server driver: Http3Connection (per-connection driver mounted on Handler), Http3Config (SETTINGS carrier -- max field section size, QPACK table caps, CONNECT-Protocol toggle, GOAWAY soft cap), Http3StreamType (RFC 9114 §6.2 codepoints). feed_stream_chunk drives Http3RequestReader -> Handler -> response writer; take_response_frames drains encoded bytes; CONTROL + QPACK uni-stream dispatch consumes SETTINGS / GOAWAY / MAX_PUSH_ID and replays peer QPACK encoder-stream inserts into a per-connection dynamic table (take_qpack_decoder_frames drains the owed Insert Count Increment); fuzz-covered (fuzz-h3-server)
flare.http3.server
HTTP/3 incremental server streaming (K1): a handler returning stream_response / stream_sse_response emits HEADERS first, then pumps one DATA frame per tick from the stashed (boxed) ChunkSource with a persistent per-stream send offset, MTU-bounded by datagram fragmentation, deferring FIN + trailers to end-of-stream — the same wire-agnostic body-stream path as H1 chunked / H2 DATA (buffered path stays byte-identical)
ALPN -> wire-protocol dispatcher: WireProtocol codepoints (UNKNOWN / HTTP_1_1 / H2C / HTTP_2 / HTTP_3), ALPN_HTTP_1_1 / ALPN_HTTP_2 / ALPN_HTTP_3 identifiers, dispatch_alpn, dispatch_h2c_upgrade, negotiate_alpn, wire_protocol_name. The pure decision function the reactor consults after a TLS handshake completes
flare.http.alpn_dispatch
QUIC Retry address validation (RFC 9000 §8.1), server and client wired: QuicServerConfig.require_address_validation answers a token-less Initial with a Retry (HMAC token bound to peer addr + original DCID, amplification-safe) and only accepts a validated token; the client detects an inbound Retry, captures the token + server-chosen DCID, and re-sends its Initial. Codecs (encode_retry_packet / verify_retry_integrity RFC 9001 §5.8 + Appendix A.4, mint_retry_token / validate_retry_token, encode_version_negotiation) are spec-validated + fuzz-clean; a full loopback handshake-through-Retry e2e passes
QUIC DATAGRAM transport (RFC 9221): DatagramFrame + encode_datagram / FrameHandler.on_datagram, the max_datagram_frame_size transport parameter (TP_ID_MAX_DATAGRAM_FRAME_SIZE), and received datagrams surfaced on ConnectionEvents.datagrams
flare.quic.frame, flare.quic.transport_params
rustls QUIC binding: RustlsQuicConfig, RustlsQuicAcceptor, RustlsQuicSession, RustlsQuicError, QuicEncryptionLevel. C ABI shim over rustls::quic::ServerConnection (rustls 0.23); per-level CRYPTO frames feed / drain through flare_rustls_quic_feed_crypto / _take_crypto, negotiated ALPN via flare_rustls_quic_alpn
gRPC primitives on top of HTTP/2. The bottom two wire layers (LPM
framing, canonical Status codes, Metadata carrier) ship as sans-I/O
codecs. The unary server ships both the sans-I/O adapter
(GrpcUnary trait + run_unary_call) and the reactor-mounted
GrpcService over HttpServer H2, with grpc-timeout deadline
enforcement, gzip message-compression negotiation
(grpc-accept-encoding / grpc-encoding, request decompress + response
compress), and chainable interceptors (Intercepted[I, H]). A proto3
wire codec (ProtoWriter / ProtoReader) is the serializer handlers
target, and tools/proto_gen.py generates Mojo message structs
(encode/decode) from a .proto for the supported subset (messages,
nested messages, enums, scalars, repeated, singular message fields).
The standard grpc.health.v1.Health ships both Check (unary) and
Watch (HealthWatchHandler, server-streaming status transitions), and
server reflection (grpc.reflection.v1alpha) answers list_servicesplusfile_by_filename / file_containing_symbol from a registered
FileDescriptorProto registry (mountable over the bidi
ReflectionBidiHandler). The client ships unary (GrpcClient,
including base64 binary -bin metadata) plus server-streaming /
client-streaming / bidirectional. All four server shapes ship as
reactor-mounted adapters: GrpcService (unary), GrpcStreamingService
(server-streaming, now incrementally flushed -- one DATA frame per
message via the K1 body-stream path), GrpcClientStreamingService, and
GrpcBidiService. tools/proto_gen.py now also emits service-block
codegen: PATH_* consts, a typed <Service>Server trait, per-RPC byte
adapters, a typed <Service>Client stub, and a serialized
FileDescriptorProto. Still deferred: maps / oneof in the message
codegen.
Metadata carrier with binary / text key discipline (-bin suffix for binary keys, base64 transport): GrpcMetadata, GrpcMetadataEntry
flare.grpc.metadata
Unary server adapter: GrpcUnary per-method handler trait, GrpcUnaryReply typed handler return (ok(body, metadata) / err(status, metadata) factories), GrpcRequestHeaders typed request-HEADERS carrier (Optional[String] for grpc-timeout / grpc-accept-encoding), GrpcCallContext (parsed deadline + accept-encoding + initial metadata), GrpcCallOutcome (response bytes + final GrpcStatus + trailing GrpcMetadata), parse_request_headers (validates POST + content-type: application/grpc[+proto] + te: trailers case-insensitively), stitch_request_data (concatenates LPM frames from HTTP/2 DATA, rejects compressed-flag set), encode_unary_response (wraps reply in uncompressed LPM), emit_trailing_headers_status (framework-controlled trailer entries: grpc-status, optional grpc-message, optional base64 grpc-status-details-bin), run_unary_call (sans-I/O orchestration that threads the call through the handler; never raises -- header / LPM / handler failures fold into typed INVALID_ARGUMENT / INTERNAL outcomes)
flare.grpc.server
Optional binary status details: GrpcStatus.with_details(payload: List[UInt8]) attaches an opaque payload that the trailer emitter base64-encodes as grpc-status-details-bin per gRPC PROTOCOL-HTTP2
flare.grpc.status
OpenAPI
OpenAPI 3.1 spec model + deterministic JSON emitter, plus
spec_from_router which derives a spec (paths, methods, path
parameters) by walking a runtime Router. Request/response body schemas
from the typed Extracted[H] handler remain a comptime follow-up (the
Router erases the handler type at registration).
WsHandler trait + WsServer.serve[H] — stateful struct handler (per-connection state via mut self), the struct-handler twin of the def(mut WsConnection) callback
Mandatory client-mask validation, UTF-8 validation on text frames (RFC 6455)
flare.ws.frame
WS-over-HTTP/2 (RFC 8441), client + server — WsOverH2Stream + bootstrap_ws_over_h2 (client) and WsOverH2ServerStream + Http2Connection.{take_extended_connect_streams,accept_ws_over_h2,drain_stream_data} (server); CONNECT + :protocol=websocket over one h2 stream, mask discipline both directions; full paired round-trip
WsAutoClient.connect() — runtime ALPN-aware dispatcher: on wss:// with prefer_h2=True it handshakes advertising ["h2", "http/1.1"], and if the peer selects h2 drives the WS-over-HTTP/2 tunnel (bootstrap_ws_over_h2, RFC 8441 Extended CONNECT); otherwise it opens a fresh HTTP/1.1 WsClient. chosen_wire reports the outcome
WsAutoClient + WsAutoClientConfig + WsWireChoice + decide_wire — the pure decision function behind the dispatcher: consults URL scheme, prefer_h2, negotiated ALPN, and the peer's ENABLE_CONNECT_PROTOCOL SETTINGS flag (RFC 8441 §3); routes to HTTP/1.1, HTTP/2 (RFC 8441 Extended CONNECT), or FAILED. Folding this into a single WsClientprefer_h2 knob (so callers don't pick between the two client types) is the remaining polish
Sanitised 4xx / 5xx bodies: extractor messages are logged with the
request id but never echoed to the client. See
security.md for the full policy.
Configuration knobs
Env var
Effect
FLARE_REUSEPORT_WORKERS=0
Switch from per-worker SO_REUSEPORT to shared-listener EPOLLEXCLUSIVE shape (7–22 % less req/s depending on path, uniformly tighter p99.99 σ under sustained load)
FLARE_BUFRING_HANDLER=1
Opt into io_uring reactor on Linux ≥ 6.0; auto-fallback to epoll
FLARE_SOAK_WORKERS=on
Enable cross-worker WorkerHandoffPool for skewed-keepalive workloads
FLARE_QUIC_NO_BATCH=1
Force the QUIC reactor's per-datagram recvfrom drain instead of the default batched recvmmsg burst drain (Linux); use to A/B the syscall-batching win
SOAK_DURATION_SECS=<n>
Override default soak harness duration (pixi run --environment bench bench-soak-*)
ServerConfig defaults (override per-server): max_header_size (8192 B),
max_body_size (10 MiB), max_keepalive_requests (100), idle_timeout_ms
(500), read_body_timeout_ms (30_000), plus request_timeout_ms /
handler_timeout_ms. Build-time invariants (e.g. max_body_size >= max_header_size) are checked by Mojo comptime assert when used with
serve_comptime[handler, config].
Stability
The public Mojo API is stable within a minor version: patch releases
never break source for the same minor. Breaking changes only land at
minor bumps. Internal types (anything in _*.mojo, or anything in
flare.runtime.* not re-exported from the package barrel) carry no
stability guarantee.
Testing and fuzz coverage
Test code reaches for two cross-cutting helper modules that the
Mojo stdlib doesn't ship: flare.testing and flare.utils.
flare.testing ships two shapes:
TestClient[H] — FastAPI-style in-process handler exerciser.
Drives Handler.serve directly without binding a port, so
the same Request builder + assertions used in production
code paths work in unit tests. The compiler monomorphises
the parametric H so a TestClient[MyHandler] invocation
is a direct call, not a virtual dispatch.
fork_server(handler, addr) / kill_forked_server(pid) —
fork-and-serve so a single-process example or integration
test can both serve and connect to itself, with the parent
process retaining the handle.