Skip to content

Support arbitrary cron frequency durations #24

@msoedov

Description

@msoedov

parseCronFrequency() in internal/scheduler/scheduler.go:1251 uses a hardcoded switch with only 5 values (1m, 20m, 1h, 2h, 1d). Any other input silently falls back to 1 hour.

Current behavior:

func parseCronFrequency(freq string) time.Duration {
    switch freq {
    case "1m":  return 1 * time.Minute
    case "20m": return 20 * time.Minute
    case "1h":  return 1 * time.Hour
    case "2h":  return 2 * time.Hour
    case "1d":  return 24 * time.Hour
    default:    return 1 * time.Hour
    }
}

Expected behavior:
Parse arbitrary duration strings like 6h, 16m, 45m, 3d, 30s. Use a simple suffix-based parser (e.g. time.ParseDuration for Go-compatible suffixes, plus custom d suffix for days).

Acceptance criteria:

  • Supports Nm, Nh, Nd, Ns where N is any positive integer
  • Invalid input returns an error instead of silently defaulting
  • Existing cron jobs with old format still work
  • Unit test with table-driven cases

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions