Добавить X-Instance-Id, задержку drain при SIGTERM и отдельный запуск миграций

This commit is contained in:
2026-11-02 16:58:11 +03:00
parent 5b9f377783
commit 7fa8881eb3
21 changed files with 389 additions and 64 deletions
+4 -3
View File
@@ -20,8 +20,9 @@ const (
)
// NewEngine builds an engine whose every response, including routing
// failures and panics, carries X-Request-Id and the contract error body.
func NewEngine(log *slog.Logger, maxBodyBytes int64) *gin.Engine {
// failures and panics, carries X-Instance-Id, X-Request-Id and the contract
// error body.
func NewEngine(log *slog.Logger, maxBodyBytes int64, instanceID string) *gin.Engine {
gin.SetMode(gin.ReleaseMode)
e := gin.New()
// Redirects would answer with text/plain and without a request id.
@@ -29,7 +30,7 @@ func NewEngine(log *slog.Logger, maxBodyBytes int64) *gin.Engine {
e.RedirectFixedPath = false
e.HandleMethodNotAllowed = true
e.Use(requestID(log), accessLog(), recovery(), bodyLimit(maxBodyBytes))
e.Use(instance(instanceID), requestID(log), accessLog(), recovery(), bodyLimit(maxBodyBytes))
e.NoRoute(func(c *gin.Context) { Error(c, apperr.NotFound("route not found")) })
e.NoMethod(func(c *gin.Context) { Fail(c, http.StatusMethodNotAllowed, "invalid_request", "method not allowed") })
return e