ecron

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 14 Imported by: 9

Documentation

Index

Constants

View Source
const PackageName = "task.ecron"

Variables

View Source
var (
	// Every ...
	Every = cron.Every
	// NewParser ...
	NewParser = cron.NewParser
	// NewChain ...
	NewChain = cron.NewChain
	// WithSeconds ...
	WithSeconds = cron.WithSeconds
	// WithParser ...
	WithParser = cron.WithParser
	// WithLocation ...
	WithLocation = cron.WithLocation
)

Functions

This section is empty.

Types

type Component

type Component struct {
	Config *Config
	*cron.Cron
	// contains filtered or unexported fields
}

Component ...

func (*Component) AddFunc

func (c *Component) AddFunc(spec string, cmd func() error) (EntryID, error)

AddFunc ...

func (*Component) AddJob

func (c *Component) AddJob(spec string, cmd NamedJob) (EntryID, error)

AddJob ...

func (*Component) GetEntryByName

func (c *Component) GetEntryByName(name string) cron.Entry

GetEntryByName ...

func (*Component) Init

func (c *Component) Init() error

func (*Component) Name

func (c *Component) Name() string

func (*Component) PackageName

func (c *Component) PackageName() string

func (*Component) Schedule

func (c *Component) Schedule(schedule Schedule, job NamedJob) EntryID

Schedule ...

func (*Component) Start

func (c *Component) Start() error

Start ...

func (*Component) Stop

func (c *Component) Stop() error

Stop ...

type Config

type Config struct {
	WithSeconds      bool          // 是否使用秒作解析器,默认否
	ConcurrentDelay  int           // 并发延迟,默认是执行超过定时时间后,下次执行的任务会跳过
	ImmediatelyRun   bool          // 是否立刻执行,默认否
	DistributedTask  bool          // 是否分布式任务,默认否,如果存在分布式任务,则会解析嵌入的etcd配置
	WaitLockTime     time.Duration // 抢锁等待时间,默认0s
	Endpoints        []string      // etcd地址
	ConnectTimeout   time.Duration // 连接超时时间,默认5s
	Secure           bool          // 是否安全通信,默认false
	AutoSyncInterval time.Duration // 自动同步member list的间隔
	TTL              int           // 过期时间,单位:s,默认失效时间为0s
	WorkerLockDir    string        // 定时任务锁目录
	// contains filtered or unexported fields
}

Config ...

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig ...

type Container

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

func DefaultContainer

func DefaultContainer() *Container

func Load

func Load(key string) *Container

func (*Container) Build

func (c *Container) Build(options ...Option) *Component

Build ...

type Ecron

type Ecron interface {
	standard.Component
}

type Entry

type Entry = cron.Entry

Entry ...

type EntryID

type EntryID = cron.EntryID

EntryID ...

type FuncJob

type FuncJob func() error

FuncJob ...

func (FuncJob) Name

func (f FuncJob) Name() string

Name ...

func (FuncJob) Run

func (f FuncJob) Run() error

Run ...

type Job

type Job = cron.Job

Job ...

type JobWrapper

type JobWrapper = cron.JobWrapper

JobWrapper ...

type Locker

type Locker interface {
	Lock(context.Context) error
	Unlock(context.Context) error
}

type NamedJob

type NamedJob interface {
	Run() error
	Name() string
}

NamedJob ..

type Option

type Option func(c *Container)

func WithChain

func WithChain(wrappers ...JobWrapper) Option

WithChain ...

func WithLocker

func WithLocker(locker Locker) Option

WithLocker 注入分布式locker

type Parser

type Parser = cron.Parser

Parser ...

type Schedule

type Schedule = cron.Schedule

Schedule ...

Jump to

Keyboard shortcuts

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