ecron

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 15 Imported by: 12

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 {
	*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 {
	WaitLockTime          time.Duration // 抢锁等待时间,默认60s
	LockTTL               time.Duration // 租期,默认60s
	LockDir               string        // 定时任务锁目录
	RefreshTTL            time.Duration // 刷新ttl,默认60s
	WaitUnlockTime        time.Duration // 抢锁等待时间,默认1s
	DelayExecType         string        // skip,queue,concurrent,如果上一个任务执行较慢,到达了新任务执行时间,那么新任务选择跳过,排队,并发执行的策略,新任务默认选择skip策略
	EnableDistributedTask bool          // 是否分布式任务,默认否,如果存在分布式任务,会只执行该定时人物
	EnableImmediatelyRun  bool          // 是否立刻执行,默认否
	EnableWithSeconds     bool          // 是否使用秒作解析器,默认否
	// 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(ctx context.Context, key string, ttl time.Duration) error
	Unlock(ctx context.Context, key string) error
	Refresh(ctx context.Context, key string, ttl time.Duration) error
}

go get github.com/gotomicro/eredis@v0.2.0+

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