cron

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: MIT Imports: 5 Imported by: 0

README

cron

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(job Job)

func Unregister

func Unregister(jobName string)

Types

type Job

type Job struct {
	Name     string
	Trigger  Trigger
	Callback func()
}

type Moment

type Moment struct {
	Any    bool
	Hour   int
	Minute int
	Second int
}

If `Any` is true, other conditions are ignored; time condition with units larger than period unit are ignored, e.g. if trigger condition is "every minute", only `Second` is considered

type Period

type Period struct {
	Every int
	Unit  TimeUnit
}

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

type TimeUnit

type TimeUnit int
const (
	Day    TimeUnit = 1
	Hour   TimeUnit = 2
	Minute TimeUnit = 3
	Second TimeUnit = 4
)

func (TimeUnit) Seconds

func (u TimeUnit) Seconds() int64

type Trigger

type Trigger struct {
	Every Period
	At    Moment
	// if last trigger has not finished, new trigger won't fire
	OneAfterAnother bool
}

Trigger condition for cron jobs, like "every day at 12:00" etc.

Jump to

Keyboard shortcuts

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