cronx

package
v0.0.0-...-11273d6 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJobKey

func GetJobKey(md *Metadata) string

Types

type Cronx

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

func New

func New(opts ...Option) *Cronx

func (*Cronx) AddFunc

func (cx *Cronx) AddFunc(spec string, cmd func(context.Context) error, mds ...map[string]string) (int, error)

func (*Cronx) AddJob

func (cx *Cronx) AddJob(spec string, job Job, mds ...map[string]string) (int, error)

func (*Cronx) AddTimerFunc

func (cx *Cronx) AddTimerFunc(t time.Time, cmd func(context.Context) error, mds ...map[string]string) int

func (*Cronx) AddTimerJob

func (cx *Cronx) AddTimerJob(t time.Time, job Job, mds ...map[string]string) int

func (*Cronx) Entries

func (cx *Cronx) Entries() []Entry

func (*Cronx) Entry

func (cx *Cronx) Entry(id int) Entry

func (*Cronx) Remove

func (cx *Cronx) Remove(id int)

func (*Cronx) RunJob

func (cx *Cronx) RunJob(job Job, mds ...map[string]string) error

func (*Cronx) Start

func (cx *Cronx) Start()

func (*Cronx) Stop

func (cx *Cronx) Stop() context.Context

type Entry

type Entry cron.Entry

func (Entry) Key

func (e Entry) Key() string

func (Entry) Meta

func (e Entry) Meta() *Metadata

func (Entry) Valid

func (e Entry) Valid() bool

type FuncJob

type FuncJob func(ctx context.Context) error

func (FuncJob) Run

func (fj FuncJob) Run(ctx context.Context) error

type Job

type Job interface {
	Run(ctx context.Context) error
}

func AttachMiddleware

func AttachMiddleware(job Job, ms ...JobMiddleware) Job

type JobMiddleware

type JobMiddleware func(Job) Job

type Metadata

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

func GetMetadata

func GetMetadata(ctx context.Context) *Metadata

func NewMetadata

func NewMetadata(datas ...map[string]string) *Metadata

func (*Metadata) Get

func (md *Metadata) Get(key string) (string, bool)

type Option

type Option func(*Cronx)

func WithCronOption

func WithCronOption(opts ...cron.Option) Option

func WithMiddleware

func WithMiddleware(m ...JobMiddleware) Option

type TimerSchedule

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

func NewTimerSchedule

func NewTimerSchedule(t time.Time) *TimerSchedule

func (TimerSchedule) Next

func (ts TimerSchedule) Next(now time.Time) time.Time

Jump to

Keyboard shortcuts

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