Repository navigation
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. Usemiddleware.FixedWindow(middleware.FixedWindowConfig{Requests: 100, Window: time.Minute, MaxKeys: 50000}); Courrier'sRateLimitBybecomesKeyFunc. Same window shape and envelope as before. Import.../middleware. - Perception: delete
internal/middleware/ratelimit.goand use the existingmiddleware.Ratelimit(recipe indocs/ratelimit.md). ItsRetry-Afterbecomes 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.goand mountmiddleware.Gzip. It now compresses only text, JSON, XML, JavaScript and SVG, skips Range, Upgrade, event-stream, 204 and 304, and addsVary: 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) withtestdb.AssertModelsMatch(t, db, queryModels...). Perception's pgvector column passestestdb.MatchOptions{Extra: ...}viaAssertModelsMatchWith. The porte and MCP schema-drift tests (Plume, Courrier, Echo, Prisme) stay. - Hand-rolled harnesses: Echo and Journal delete
internal/testdb/testdb.goand calltestdb.OpenIsolatedwithtestdb.URLFrom("ECHO_TEST_DATABASE_URL"); Antenne deletesinternal/pgtest; Casier deletesinternal/testdbfortestdb.Openplustestdb.LockID; Sablier usesOpen,TruncateandLockID; Place setsConfig.SearchPathTail: []string{"public"}. Nuage'stests/helpers_test.godrops and recreatespublic; move it toOpenandTruncate.
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}.goand their tests; keepproxy.go, qualify its calls withnetguard.. UseGuard.ClientFollowing(timeout)where redirects must be followed (add the cookie jar locally). - Journal
modules/alerts/safeguard.go: deleteisBlockedIP, setControl: netguard.Controlon the dialer. - Plume: delete
internal/urlsafe;netguard.CheckURLat save time and(&netguard.Guard{}).Client(timeout)for delivery. - Nuage
modules/settings/service.go: deleteisPrivateAddress, callnetguard.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: replaceisPublicIP,embeddedIPv4andblockedNetworks(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.Stringand the typed helpers) is still skipped by GoSvelteBoilerplate, Place and Sonde, which hand-rollos.Getenvconfig (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.