From aff60af8ba24c8d5330c706ddf26927d81436d79 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 26 Jan 2026 08:08:17 -1000 Subject: Phase 4: Extract magic numbers to constants Create config/constants.go with centralized configuration values: - Concurrency limits (MaxConcurrentTrelloRequests) - Timeouts (HTTP, Google Calendar, graceful shutdown, request) - Meal times (breakfast, lunch, dinner hours) - Database pool settings (connections, lifetime) - Session and rate limiting settings Update all files to use these constants instead of hardcoded values. Co-Authored-By: Claude Opus 4.5 --- internal/config/constants.go | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 internal/config/constants.go (limited to 'internal/config') diff --git a/internal/config/constants.go b/internal/config/constants.go new file mode 100644 index 0000000..a199404 --- /dev/null +++ b/internal/config/constants.go @@ -0,0 +1,51 @@ +package config + +import "time" + +// Concurrency limits +const ( + // MaxConcurrentTrelloRequests limits parallel Trello API calls + MaxConcurrentTrelloRequests = 5 +) + +// Timeouts +const ( + // HTTPClientTimeout is the default timeout for HTTP clients + HTTPClientTimeout = 15 * time.Second + + // GoogleCalendarInitTimeout is the timeout for Google Calendar initialization + GoogleCalendarInitTimeout = 30 * time.Second + + // GracefulShutdownTimeout is the timeout for server graceful shutdown + GracefulShutdownTimeout = 10 * time.Second + + // RequestTimeout is the timeout for individual HTTP requests + RequestTimeout = 60 * time.Second +) + +// Default meal times (24-hour format) +const ( + BreakfastHour = 8 + LunchHour = 12 + DinnerHour = 19 +) + +// Database connection pool settings +const ( + SQLiteMaxOpenConns = 5 + SQLiteMaxIdleConns = 2 + SQLiteConnMaxLifetime = time.Hour +) + +// Session settings +const ( + SessionLifetime = 24 * time.Hour +) + +// Rate limiting +const ( + // AuthRateLimitRequests is max login attempts per window + AuthRateLimitRequests = 5 + // AuthRateLimitWindow is the time window for rate limiting + AuthRateLimitWindow = 15 * time.Minute +) -- cgit v1.2.3