addHourlyCronWarning emits a warning when an hourly interval with fixed minute is detected
(cronExpr string)
| 488 | |
| 489 | // addHourlyCronWarning emits a warning when an hourly interval with fixed minute is detected |
| 490 | func (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 |
| 516 | func (c *Compiler) addWeeklyCronWarning(cronExpr string) { |
no test coverage detected