various: extract magic numbers into named constants

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I854b2f9b5f39e4629c32e5681e6322826a6a6964
This commit is contained in:
raf 2026-03-01 21:14:07 +03:00
commit 7b06c4f2ca
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
4 changed files with 22 additions and 9 deletions

View file

@ -11,13 +11,13 @@ import (
"path/filepath"
"strings"
"syscall"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"notashelf.dev/watchdog/internal/aggregate"
"notashelf.dev/watchdog/internal/api"
"notashelf.dev/watchdog/internal/config"
"notashelf.dev/watchdog/internal/limits"
"notashelf.dev/watchdog/internal/normalize"
)
@ -91,9 +91,9 @@ func Run(cfg *config.Config) error {
srv := &http.Server{
Addr: cfg.Server.ListenAddr,
Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 60 * time.Second,
ReadTimeout: limits.HTTPReadTimeout,
WriteTimeout: limits.HTTPWriteTimeout,
IdleTimeout: limits.HTTPIdleTimeout,
}
// Start server in goroutine
@ -115,8 +115,8 @@ func Run(cfg *config.Config) error {
case sig := <-shutdown:
log.Printf("Received signal: %v, starting graceful shutdown", sig)
// Give outstanding requests 30 seconds to complete
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
// Give outstanding requests time to complete
ctx, cancel := context.WithTimeout(context.Background(), limits.ShutdownTimeout)
defer cancel()
// Shutdown metrics aggregator.