Skip to content

v0.26.0

Latest

Choose a tag to compare

@saravenpi saravenpi released this 15 Nov 23:47
· 2 commits to main since this release
5c76aab

Additive release. Nothing existing changes. New: httpx.Serve, httpx.WriteBudget, middleware.FixedWindow, middleware.Gzip, health.Version, netguard. Released with testdb/v0.2.0 (see below). Full list in CHANGELOG.md.

MIGRATION: what each app deletes and what it imports

Tronc imports are all github.com/FacileStudio/tronc/<pkg>. Bump tronc to v0.26.0 and tronc/testdb to v0.2.0 first.

1. Serve and graceful shutdown (all 24 backends)

Delete the &http.Server{...}, the ListenAndServe goroutine, the select on serverErrCh and the server.Shutdown block in main.go. Import .../httpx and call httpx.Serve(ctx, router, httpx.ServeConfig{Addr: addr, Logger: logger}), where ctx comes from signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM). It returns nil after a clean stop.

Defaults: read header 5s, read 30s, write 60s, idle 120s, shutdown grace 15s. Zero takes the default, a negative value means no limit. Serve never wraps the ResponseWriter, so SSE, WebSocket and http.ResponseController keep working.

Keep today's behaviour with these settings:

App Set
Bulle WriteTimeout: -1, OnShutdown: []func(){pushSender.CloseStreams} (HTTP/2 resets a stream at an expired write deadline; model output streams for minutes)
Nuage ReadTimeout: -1, WriteTimeout: -1, ShutdownGrace: 45*time.Second, MaxHeaderBytes: 1<<20 (multi-gigabyte transfers)
Courrier ReadTimeout: 10*time.Second, WriteTimeout: 15*time.Second, IdleTimeout: 60*time.Second. Its assist and push handlers already move their own deadlines with ResponseController, which still works.
Echo ReadTimeout/WriteTimeout: 30*time.Second, ShutdownGrace: 10*time.Second. Replace extendWriteDeadline(suffix, d) with httpx.WriteBudget(d) on the summary and recording routes (r.With(...)), then delete the helper.
Antenne Nothing: it gains read, write and idle timeouts it never had. Check any long route first.
Everyone else Nothing, or copy the 5/10/15/60 values if a route depends on them.

2. Rate limiter and gzip

  • Agenda and Courrier: delete apps/api/internal/middleware/ratelimit.go. Use middleware.FixedWindow(middleware.FixedWindowConfig{Requests: 100, Window: time.Minute, MaxKeys: 50000}); Courrier's RateLimitBy becomes KeyFunc. Same window shape and envelope as before. Import .../middleware.
  • Perception: delete internal/middleware/ratelimit.go and use the existing middleware.Ratelimit (recipe in docs/ratelimit.md). Its Retry-After becomes the computed wait instead of 60.
  • Echo: stays app-side (identity-dependent budgets, /64 and /48 buckets). Documented in docs/ratelimit.md.
  • Agenda and Courrier: delete apps/api/internal/middleware/gzip.go and mount middleware.Gzip. It now compresses only text, JSON, XML, JavaScript and SVG, skips Range, Upgrade, event-stream, 204 and 304, and adds Vary: Accept-Encoding.

3. testdb (tronc/testdb v0.2.0)

  • Model drift: in each of Agenda, Courrier, Echo, GoSvelteBoilerplate, Journal, Nuage, Perception, Place, Plume, Prisme, Sablier, Vision (and Capsule/Casier where present), replace the body of schemas/columns_test.go (compatibleTypes, migratedColumnTypes, the loop) with testdb.AssertModelsMatch(t, db, queryModels...). Perception's pgvector column passes testdb.MatchOptions{Extra: ...} via AssertModelsMatchWith. The porte and MCP schema-drift tests (Plume, Courrier, Echo, Prisme) stay.
  • Hand-rolled harnesses: Echo and Journal delete internal/testdb/testdb.go and call testdb.OpenIsolated with testdb.URLFrom("ECHO_TEST_DATABASE_URL"); Antenne deletes internal/pgtest; Casier deletes internal/testdb for testdb.Open plus testdb.LockID; Sablier uses Open, Truncate and LockID; Place sets Config.SearchPathTail: []string{"public"}. Nuage's tests/helpers_test.go drops and recreates public; move it to Open and Truncate.

4. netguard (security: one copy)

Import .../netguard.

  • Registre: delete apps/api/internal/netguard/ (6 files). Guard.Client(timeout, roots) becomes (&netguard.Guard{TLS: roots}).Client(timeout).
  • sonar: delete internal/netguard/{ranges,guard,dial}.go and their tests; keep proxy.go, qualify its calls with netguard.. Use Guard.ClientFollowing(timeout) where redirects must be followed (add the cookie jar locally).
  • Journal modules/alerts/safeguard.go: delete isBlockedIP, set Control: netguard.Control on the dialer.
  • Plume: delete internal/urlsafe; netguard.CheckURL at save time and (&netguard.Guard{}).Client(timeout) for delivery.
  • Nuage modules/settings/service.go: delete isPrivateAddress, call netguard.CheckURL, and send the webhook with a guarded client (today only the save-time check exists, so a rebinding name passes).
  • porte oidc/avatar.go: replace isPublicIP, embeddedIPv4 and blockedNetworks (needs tronc >= v0.26.0 in porte).
  • Unguarded today, add a guard or document why not: Sonde (checker probes and webhooks), Antenne (webhooks, delivery senders and probes), Casier and Echo webhooks, Vision webhooks. Gare's ingress probe is a loopback probe, not an SSRF guard.

5. health.Version

Agenda, Bulle, Casier, Courrier, Echo, Journal, Prisme, Sonde (identical 13-line apps/api/version.go), and Bobine, Capsule, Opus, Vision, Sablier (variants): delete versionHandler, keep var version = "dev" in main.go for -ldflags "-X main.version=...", and mount router.Get("/version", health.Version(version)). Import .../health (already imported for Mount). The answer now carries Cache-Control: no-store.

Notes

  • tronc/env (env.LoadCore, env.String and the typed helpers) is still skipped by GoSvelteBoilerplate, Place and Sonde, which hand-roll os.Getenv config (about 700 lines). GoSvelteBoilerplate seeds every new app, so fix it first.
  • The GitHub release for v0.25.0 was missing; it is created with this one.