feat(httpserver): promote to v1.0.2 — configurable ShutdownTimeout, bump deps to v1.0.1, go 1.26

Add Config.ShutdownTimeout (SERVER_SHUTDOWN_TIMEOUT, default 10s) so callers can
configure the graceful-shutdown deadline without code changes. Previously hardcoded
to 10 seconds. Bump launcher and logz from v0.9.0 to v1.0.1, update go directive
from 1.25 to 1.26. API committed as stable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-12 04:17:52 +00:00
parent 1801754a9b
commit ff51f26819
4 changed files with 30 additions and 13 deletions

View File

@@ -5,6 +5,17 @@ All notable changes to this module will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.0.2] - 2026-05-12
### Added
- `Config.ShutdownTimeout time.Duration` (`SERVER_SHUTDOWN_TIMEOUT`, default `10s`) — configures the graceful-shutdown deadline passed to `http.Server.Shutdown`. Previously hardcoded to 10 seconds; callers that serve long-running requests (uploads, streaming) or prefer a shorter fail-fast window can now set this per environment.
### Changed
- `launcher` and `logz` dependencies bumped from v0.9.0 to v1.0.1.
- `go` directive updated from 1.25 to 1.26.
## [0.9.2] - 2026-03-25
### Fixed
@@ -44,6 +55,7 @@ and this module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.
- No middleware is installed by default; the full middleware stack is composed explicitly via `WithMiddleware` at construction time, keeping the stack visible and ordering unambiguous in the application source
- chi was chosen as the underlying router because it uses stdlib `http.Handler` throughout, making it fully compatible with `httpmw` middleware and `httputil` handler adapters without any wrapper code at the boundary
[1.0.2]: https://code.nochebuena.dev/go/httpserver/releases/tag/v1.0.2
[0.9.2]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.2
[0.9.1]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.1
[0.9.0]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.0

6
go.mod
View File

@@ -1,10 +1,10 @@
module code.nochebuena.dev/go/httpserver
go 1.25
go 1.26
require (
code.nochebuena.dev/go/launcher v0.9.0
code.nochebuena.dev/go/launcher v1.0.1
github.com/go-chi/chi/v5 v5.2.1
)
require code.nochebuena.dev/go/logz v0.9.0 // indirect
require code.nochebuena.dev/go/logz v1.0.1 // indirect

8
go.sum
View File

@@ -1,6 +1,6 @@
code.nochebuena.dev/go/launcher v0.9.0 h1:dJHonA9Xm03AQKK0919FJaQn9ZKHZ+RZfB9yxjnx3TA=
code.nochebuena.dev/go/launcher v0.9.0/go.mod h1:IBtntmbnyddukjEhxlc7Ysdzz9nZsnd9+8FzAIHt77g=
code.nochebuena.dev/go/logz v0.9.0 h1:wfV7vtI4V/8ED7Hm31Fbql7Y5iOGrlHN4X8Z5ajTZZE=
code.nochebuena.dev/go/logz v0.9.0/go.mod h1:qODhSbKb+tWE7rdhHLcKweiP5CgwIaWoZxadCT3bQV8=
code.nochebuena.dev/go/launcher v1.0.1 h1:hbPV8jNtyxfchrT7igzz3M2tKGI3bm8uWkHBXRvSPgg=
code.nochebuena.dev/go/launcher v1.0.1/go.mod h1:1KwndVuqm31JN9Dpl9YvOmlogPlKKzoDMo9aRFkYwmM=
code.nochebuena.dev/go/logz v1.0.1 h1:kK9aZo19L208CwCr2D/dbSOMaOv62cXsigMSsdFu+8Y=
code.nochebuena.dev/go/logz v1.0.1/go.mod h1:YNpNm03fURm2v0ySh/477z9AJhtfRcd9rFOW6fFqgNM=
github.com/go-chi/chi/v5 v5.2.1 h1:KOIHODQj58PmL80G2Eak4WdvUzjSJSm0vG72crDCqb8=
github.com/go-chi/chi/v5 v5.2.1/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=

View File

@@ -26,6 +26,7 @@ type Config struct {
ReadTimeout time.Duration `env:"SERVER_READ_TIMEOUT" envDefault:"5s"`
WriteTimeout time.Duration `env:"SERVER_WRITE_TIMEOUT" envDefault:"10s"`
IdleTimeout time.Duration `env:"SERVER_IDLE_TIMEOUT" envDefault:"120s"`
ShutdownTimeout time.Duration `env:"SERVER_SHUTDOWN_TIMEOUT" envDefault:"10s"`
}
// serverOpts holds functional options.
@@ -125,7 +126,11 @@ func (s *httpServer) OnStop() error {
return nil
}
s.logger.Info("httpserver: shutting down gracefully")
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
timeout := s.cfg.ShutdownTimeout
if timeout == 0 {
timeout = 10 * time.Second
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
return s.srv.Shutdown(ctx)
}