Public API
API freeze target
The public surface below is the freeze target for 0.5.5. After 0.5.5, zero follows SemVer: any breaking change to a name listed here requires a two-release deprecation window (@deprecated alias kept, removal in the following minor). Additions and non-breaking fixes are allowed in patch and minor releases. The authoritative source of truth is src/zero.zig.
The public import name is zero. Consumers do @import("zero") and reach every type below through it. For the type-erased interface machinery behind the backends, see Interface; for the upgrade and deprecation policy, see Upgrade policy.
Application lifecycle
| Symbol | Kind | Purpose |
|---|---|---|
App | struct | Top-level app; App.new, app.run, app.get/post/... |
Context | struct | Per-request context: ctx.request, ctx.response, ctx.SQL, ctx.NoSQL, ctx.KV, ctx.FileStore, ctx.pubsub, ctx.params |
container | struct | Backend wiring (container.datasource, container.redis, pub/sub, file stores) |
logger | namespace | logger.custom — zero's stderr/stdout logger |
config | namespace | .env loading and typed accessors |
constants | namespace | Well-known paths, defaults, enum maps |
App.addSQL, App.addPubSub | methods | Register named SQL / pub/sub backends; look them up via ctx.GetSQL(name) / ctx.GetPubSub(name) |
Context.GetSQL, Context.GetPubSub, Context.GetKVStore, Context.GetFileStore, Context.getService | methods | Named lookups; the default backend is unchanged on ctx.SQL / ctx.pubsub / ctx.KV / ctx.FileStore |
HTTP, middleware & observability
| Symbol | Kind | Purpose |
|---|---|---|
httpServer, handler, responder | namespaces | HTTP server, dispatch, response helpers |
rateLimiter | namespace | @import("zero").rateLimiter — in-memory/Redis rate limiting |
tracz, baggage, otel | namespaces | Tracing, W3C baggage, OpenTelemetry bridge |
metricz, metriczServer | namespaces | Prometheus metrics + scrape endpoint |
Auth & security
| Symbol | Kind | Purpose |
|---|---|---|
AuthProvider | struct | Basic / API-key / OAuth verification (AuthProvider.retrieveClaims) |
jwtClaims | type | Decoded JWT claims |
authz | namespace | Authorization helpers |
rbac | namespace | Role-based access control |
Datasources
| Symbol | Kind | Purpose |
|---|---|---|
SQL | struct | Unified SQL dialect entry (ctx.SQL) |
App.addSQL(name, ds) / Context.GetSQL(name) | methods | Named SQL datasources alongside the default (ctx.SQL); the wired default is also under the "default" key |
Datasource (Interface) | interface | Type-erased SQL backend |
SQLite, DuckDB, DuckGres, ClickHouse, MySQL | structs | SQL backends |
Timeseries, InfluxDB, OpenTSDB | structs | Time-series backends |
Search, Solr, Meili | structs | Search backends |
Graph, Dgraph | structs | Graph backend |
NoSQL, Cassandra, Couchbase, MongoDB, ArangoDB | structs | NoSQL backends |
migration, migrate | namespaces | Schema migrations & seeding |
App.addOutbox(opts) / outbox.enqueue(ctx, table, topic, payload) | method / fn | Opt-in transactional outbox: enqueue a message inside your DB transaction, a cron poller publishes pending rows to the configured pub/sub backend with a retry/attempts cap |
KV, file stores & pub/sub
| Symbol | Kind | Purpose |
|---|---|---|
KVStore (interface) | interface | Key/value store |
FileStore (interface), UploadedFile | interface / type | File storage + uploaded file |
pubsub interface (Container, Subscriber, Publisher) | interface | Type-erased pub/sub |
App.addPubSub(name, ps) / Context.GetPubSub(name) | methods | Named pub/sub backends alongside the default (ctx.pubsub); the wired default is also under the "default" key |
kafka, kafkaSubscriber, kafkaMessage | namespaces | Apache Kafka backend |
mqtt, nats, rdz (Redis), sqs, gcppubsub | namespaces | Other pub/sub backends |
Service client, protobuf & websockets
| Symbol | Kind | Purpose |
|---|---|---|
client (Client) | struct | Outbound HTTP client with auth + circuit breaker |
protobuf | namespace | Protobuf encode/decode |
WebSocketClient (Client) | struct | Outbound WebSocket client |
Utilities
| Symbol | Kind | Purpose |
|---|---|---|
utils | namespace | String/format helpers, timestamps |
sysinfo (zf) | namespace | Host metrics (CPU/mem/process) |
Upgrade policy
0.x.ypatch: security/regression fixes only, no API change.0.x.0minor: new backends/options, deprecations; interface-compatible.1.0.0+: semver, interface changes are majors.
Before you upgrade:
- Bump
minimum_zig_versionin yourbuild.zig.zonto match the newzero. - Read the relevant section of Release Notes for your from→to range.
- Run
zig build testandzig build test-integration— the datasource parity tests catch dialect drift early.
Notable breaking changes are announced here, in chronological order:
- OTel promotion —
OTEL_EXPERIMENTALwas removed; OpenTelemetry is enabled by setting an OTLP endpoint (OTEL_EXPORTER_OTLP_ENDPOINTor per-signal*_ENDPOINT). Drop the experimental flag from your env. - Named backends —
app.addSQL(name, ds)/app.addPubSub(name, ps)andctx.GetSQL(name)/ctx.GetPubSub(name); the wired default is also under the"default"key. Code that only usedctx.SQLis unchanged. - Transactional outbox —
app.addOutbox(opts)ships a poller; opt-in, no behavior change unless you call it. - Redis resilience —
container.rdz.reconnect()added; the health probe heals a dead socket automatically. No API change, but Redis-dependent behavior now recovers without a restart. - Kafka TLS default —
KAFKA_TLS_INSECURE_SKIP_VERIFYnow defaults tofalse(cert verification on). Set it totrueonly if you deliberately accept unverified certs.
Deprecated symbols are kept for one minor release, logged at startup, and removed in the next minor. Pin a version and watch startup logs after upgrading. See also Migrating to 0.16.
Notes
- The earlier misspellings
AuthProvder,Kakfa, andonStatupwere corrected toAuthProvider,container.Kafka, andonStartup. Do not reintroduce the old spellings. - Optional heavy backends are build flags in
build.zig:-Dkafka=falseand-Dduckdb=falsedroplibrdkafka/libduckdbfrom the build. - Pin the Zig version and the
zerocommit you build against until 1.0; the interface may still change between minor releases.