Refactor settings handling to support context-based reloading and add utility functions for context management
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-19 11:06:05 +11:00
parent f2d6b3158b
commit 504621f80d
5 changed files with 50 additions and 4 deletions

View File

@@ -15,12 +15,17 @@ import (
"vctp/db"
"vctp/internal/metrics"
"vctp/internal/report"
"vctp/internal/settings"
)
// RunVcenterDailyAggregate summarizes hourly snapshots into a daily summary table.
func (c *CronTask) RunVcenterDailyAggregate(ctx context.Context, logger *slog.Logger) (err error) {
jobTimeout := durationFromSeconds(c.Settings.Values.Settings.DailyJobTimeoutSeconds, 15*time.Minute)
return c.runAggregateJob(ctx, "daily_aggregate", jobTimeout, func(jobCtx context.Context) error {
if err := c.Settings.ReadYMLSettings(); err != nil {
return err
}
jobCtx = settings.MarkReloadedInContext(jobCtx, c.Settings)
startedAt := time.Now()
defer func() {
logger.Info("Daily summary job finished", "duration", time.Since(startedAt))