Skip to content

0.2.0

Choose a tag to compare

@xuckless xuckless released this 23 Oct 07:18
· 391 commits to main since this release

0.2.0 is the API review I wanted done before the Node and Python bindings build on Anole. It batches every breaking change of the 0.x API in one release, so there's a migration to do; docs/migrating.md has an old -> new table for each area.

zig fetch --save git+https://github.com/xuckless/anole#v0.2.0

Breaking, in short

  • Options are flat and typed. ServerOptions.server is gone: its settings are flat timeouts, limits and proxy groups named as in the C ABI. Durations are anole.Duration (.fromSeconds(10)), TLS has one shape everywhere (anole.Cert), and every middleware is built with init(.{ ... }).
  • Errors are named sets. init, listen, listenTls, run and waitReady return anole.ServerError; misusing a request or response (a second req.reader(), ...) is a MisuseError, not an assert.
  • Safer defaults. The graceful drain waits 10 s (was 30 s), WebSocket messages are capped at 1 MiB (was 16 MiB), and database calls are bounded by 30 s unless a call opts out.
  • Databases speak one vocabulary across SQLite, PostgreSQL, MongoDB and Redis (table/execValues, one Options shape).
  • C ABI 0.7. Request calls share the anole_req_ prefix, cleanup calls are idempotent, ANOLE_EV_ABORT says why, request records are 128 bytes, and event types and handle kinds have one frozen allocation table. A library only serves code built against the same ABI version before 1.0, so rebuild against the new anole.h.

New

  • app.listen("3000") listens on every interface; app.rateLimit(.{ .limit = 100 }) is a one-line rate limiter.
  • WebSocket subprotocols and handshake headers, handshakes decided by the application (also in the C ABI), and in-order publishes per topic.
  • timeouts.write, req.setDeadline, req.readerLimited, res.headersSent(), EventStream.comment for heartbeats.
  • C ABI: database transactions (anole_db_begin), queries tied to the request they serve, anole_server_open, anole_last_error_name(), and include/anole.abi.json for binding generators.

Fixed

Among others: event streams and downloads are no longer cut at the request timeout, setting any http2 option no longer drops the stream limit, C ABI executors no longer spin while a consumer is idle, and a server with many thousands of connections on one core accepts new ones promptly again (p99 at 25,000 connections went from about 6 s to about 0.2 s).

Checked

A 2-hour soak at half capacity across HTTP/1.1, TLS, HTTP/2 and HTTP/3: 75.4 million requests, no errors, memory flat (16.5-19.8 MB). A Debug run reports no leaks. Against 0.1.3 on one CPU: HTTP/1.1 and HTTP/2 within ±2%, HTTP/3 on epoll +14% with its p99 cut by more than half.

Full list in CHANGELOG.md.