Define ShutdownTimeout and SentryFlushTimeout constants
This commit is contained in:
@@ -21,6 +21,12 @@ import (
|
|||||||
"sneak.berlin/go/pixa/internal/middleware"
|
"sneak.berlin/go/pixa/internal/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Shutdown configuration constants.
|
||||||
|
const (
|
||||||
|
ShutdownTimeout = 5 * time.Second
|
||||||
|
SentryFlushTimeout = 2 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
// ServerParams defines dependencies for Server.
|
// ServerParams defines dependencies for Server.
|
||||||
type ServerParams struct {
|
type ServerParams struct {
|
||||||
fx.In
|
fx.In
|
||||||
@@ -125,7 +131,7 @@ func (s *Server) serve() int {
|
|||||||
|
|
||||||
func (s *Server) cleanShutdown() {
|
func (s *Server) cleanShutdown() {
|
||||||
s.exitCode = 0
|
s.exitCode = 0
|
||||||
ctxShutdown, shutdownCancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctxShutdown, shutdownCancel := context.WithTimeout(context.Background(), ShutdownTimeout)
|
||||||
defer shutdownCancel()
|
defer shutdownCancel()
|
||||||
|
|
||||||
if s.httpServer != nil {
|
if s.httpServer != nil {
|
||||||
@@ -135,7 +141,7 @@ func (s *Server) cleanShutdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if s.sentryEnabled {
|
if s.sentryEnabled {
|
||||||
sentry.Flush(2 * time.Second)
|
sentry.Flush(SentryFlushTimeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user