cron

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetUp

func SetUp(job *Cron)

SetUp set instance

Types

type Config added in v1.0.3

type Config struct {
	Enable bool                `mapstructure:"enable"`
	Specs  map[string][]string `mapstructure:"specs"` // one spec to multi events
}

Config ..

func (*Config) Events added in v1.0.3

func (config *Config) Events() (res map[string]string)

Events 返回定时任务配置

type Cron

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

Cron type

var CronJob *Cron

CronJob cron job instance

func NewCron

func NewCron(config *Config, logger log.Logger) (c *Cron)

NewCron server init

func (*Cron) AddEvent

func (c *Cron) AddEvent(name string, event Event)

AddEvent name is the unique key and event must define in cron config

func (*Cron) Start

func (c *Cron) Start()

Start cron

func (*Cron) Stop

func (c *Cron) Stop()

Stop cron

type Event

type Event func()

Event func

Jump to

Keyboard shortcuts

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