xcron

package
v1.27.9 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNil     = errors.New("key nil")
	ErrSpecNil    = errors.New("spec nil")
	ErrKeyExisted = errors.New("scheduled tasks already exist")
	ErrCmdFuncNil = errors.New("cmd func nil")
)

Functions

This section is empty.

Types

type Cron

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

func New

func New(logger Logger) *Cron

func (*Cron) AddFunc

func (c *Cron) AddFunc(spec string, cmd func(), key, name, desc string) (*Entry, error)

func (*Cron) AddJob

func (c *Cron) AddJob(spec string, cmd Job) (*Entry, error)

func (*Cron) Client

func (c *Cron) Client() *cron.Cron

func (*Cron) Entries

func (c *Cron) Entries() []*Entry

func (*Cron) Entry

func (c *Cron) Entry(key string) *Entry

func (*Cron) ExecJob

func (c *Cron) ExecJob(key string) error

func (*Cron) Has

func (c *Cron) Has(key string) bool

func (*Cron) Remove

func (c *Cron) Remove(key string)

Remove an entry from being run in the future.

func (*Cron) Start

func (c *Cron) Start()

func (*Cron) Stop

func (c *Cron) Stop()

type Entry

type Entry struct {
	ID cron.EntryID
	// Next time the job will run, or the zero time if Cron has not been
	// started or this entry's schedule is unsatisfiable
	Next time.Time
	// Prev is the last time this job was run, or the zero time if never.
	Prev time.Time
	Name string
	Desc string
	Spec string
	Key  string
	// contains filtered or unexported fields
}

func (Entry) Job

func (e Entry) Job() cron.Job

func (Entry) Run

func (e Entry) Run()

type FuncJob

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

func (*FuncJob) Desc

func (job *FuncJob) Desc() string

func (*FuncJob) Key

func (job *FuncJob) Key() string

func (*FuncJob) Name

func (job *FuncJob) Name() string

func (*FuncJob) Option

func (job *FuncJob) Option(map[string]any)

func (*FuncJob) Run

func (job *FuncJob) Run()

func (*FuncJob) SetDesc

func (job *FuncJob) SetDesc(desc string)

func (*FuncJob) SetJob

func (job *FuncJob) SetJob(cmd func())

func (*FuncJob) SetKey

func (job *FuncJob) SetKey(key string)

func (*FuncJob) SetName

func (job *FuncJob) SetName(name string)

type Job

type Job interface {
	Run()
	// Key 任务唯一key
	Key() string
	Name() string
	Desc() string
	Option(map[string]any)
}

type Logger

type Logger interface {
	cron.Logger
}

Jump to

Keyboard shortcuts

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