MCPcopy Create free account
hub / github.com/github/gh-aw / addHourlyCronWarning

Method addHourlyCronWarning

pkg/workflow/schedule_preprocessing.go:490–513  ·  view source on GitHub ↗

addHourlyCronWarning emits a warning when an hourly interval with fixed minute is detected

(cronExpr string)

Source from the content-addressed store, hash-verified

488
489// addHourlyCronWarning emits a warning when an hourly interval with fixed minute is detected
490func (c *Compiler) addHourlyCronWarning(cronExpr string) {
491 // Extract minute and interval from the cron expression
492 fields := strings.Fields(cronExpr)
493 if len(fields) >= 2 {
494 minute := fields[0]
495 hourField := fields[1]
496 schedulePreprocessingLog.Printf("Warning: detected hourly cron with fixed minute: %s", cronExpr)
497
498 // Extract the interval from */N pattern
499 interval := strings.TrimPrefix(hourField, "*/")
500
501 // Construct the warning message
502 warningMsg := fmt.Sprintf(
503 "Schedule uses hourly interval with fixed minute offset (%s). Consider using fuzzy schedule 'every %sh' instead to distribute workflow execution times and reduce load spikes.",
504 minute, interval,
505 )
506
507 // This warning is added to the warning count
508 c.IncrementWarningCount()
509
510 // Store the warning for later display
511 c.addScheduleWarning(warningMsg)
512 }
513}
514
515// addWeeklyCronWarning emits a warning when a weekly cron pattern with fixed time is detected
516func (c *Compiler) addWeeklyCronWarning(cronExpr string) {

Callers 1

Calls 3

IncrementWarningCountMethod · 0.95
addScheduleWarningMethod · 0.95
PrintfMethod · 0.45

Tested by

no test coverage detected