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

@ -9,6 +9,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"notashelf.dev/watchdog/internal/config"
"notashelf.dev/watchdog/internal/limits"
)
var prometheusLabelPattern = regexp.MustCompile(`^[a-zA-Z0-9_/:.-]*$`)
@ -121,11 +122,11 @@ func NewMetricsAggregator(
return m
}
// Background goroutine to update the unique visitors gauge every 10 seconds
// Background goroutine to update the unique visitors gauge periodically
// instead of on every request. This should help with performance.
func (m *MetricsAggregator) updateUniquesGauge() {
defer m.wg.Done()
ticker := time.NewTicker(10 * time.Second)
ticker := time.NewTicker(limits.UniquesUpdatePeriod)
defer ticker.Stop()
for {