cron

package
v0.46.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TimeLayout     = "15:04"
	DateTimeLayout = "2006-01-02 15:04"
	OnceFreq       = "once"
	WeeklyFreq     = "weekly"
	DailyFreq      = "daily"
	HourlyFreq     = "hourly"
	MinutelyFreq   = "minutely"
)

Variables

View Source
var WeekDays = []string{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}

Functions

func ParseTime

func ParseTime(layout, t, timezone string) (time.Time, error)

Types

type Entry added in v0.44.1

type Entry struct {
	ID       cron.EntryID
	TimeZone string
}

Entry identifies a cron entry together with the time zone of the cron that runs it, because entry IDs are only unique within a single cron.

type ScheduleManager

type ScheduleManager struct {
	CronByTZ  map[string]*cron.Cron
	EntryByID map[string]Entry
	TimerByID map[string]*time.Timer
	// contains filtered or unexported fields
}

func NewScheduleManager

func NewScheduleManager() *ScheduleManager

func (*ScheduleManager) InitCron

func (sm *ScheduleManager) InitCron(timezone string) (*cron.Cron, error)

func (*ScheduleManager) RemoveCronEntry

func (sm *ScheduleManager) RemoveCronEntry(entityID string)

func (*ScheduleManager) RemoveTimer added in v0.44.1

func (sm *ScheduleManager) RemoveTimer(entityID string)

func (*ScheduleManager) ScheduleOneTimeTask

func (sm *ScheduleManager) ScheduleOneTimeTask(task func(), scheduler Scheduler, entityID string) error

func (*ScheduleManager) ScheduleRepeatingTask

func (sm *ScheduleManager) ScheduleRepeatingTask(task func(), scheduler Scheduler, entityID string) error

func (*ScheduleManager) Stop

func (sm *ScheduleManager) Stop()

type Scheduler

type Scheduler struct {
	TimeZone  string `json:"time_zone"`
	Frequency string `json:"frequency"`
	DateTime  string `json:"date_time"`
	Week      Week   `json:"week"`
	DayTime   string `json:"day_time"`
	Hour      int    `json:"hour"`
	Minute    int    `json:"minute"`
}

func NormalizeTimezone

func NormalizeTimezone(scheduler Scheduler) Scheduler

func (Scheduler) IsValid

func (s Scheduler) IsValid() bool

func (Scheduler) ToCronExpression

func (s Scheduler) ToCronExpression() (string, error)

type Week

type Week struct {
	Days []string `json:"days"`
	Time string   `json:"time"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL