ecron

package
Version: v0.6.16 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 17 Imported by: 5

Documentation

Index

Constants

View Source
const PackageName = "task.ecron"

PackageName 包名

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

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

Component ...

func (*Component) Init

func (c *Component) Init() error

Init Init

func (*Component) Name

func (c *Component) Name() string

Name 名称

func (*Component) PackageName

func (c *Component) PackageName() string

PackageName 包名

func (*Component) Start

func (c *Component) Start() error

Start ...

func (*Component) Stop

func (c *Component) Stop() error

Stop ...

type Config

type Config struct {
	// Required. 触发时间
	//	默认最小单位为分钟.比如:
	//		"* * * * *" 代表每分钟执行
	//	如果 EnableSeconds = true. 那么最小单位为秒. 示例:
	//		"*/3 * * * * *" 代表每三秒钟执行一次
	Spec string

	WaitLockTime   time.Duration // 抢锁等待时间,默认 4s
	LockTTL        time.Duration // 租期,默认 16s
	RefreshGap     time.Duration // 锁刷新间隔时间, 默认 4s
	WaitUnlockTime time.Duration // 解锁等待时间,默认 1s

	DelayExecType         string // skip,queue,concurrent,如果上一个任务执行较慢,到达了新任务执行时间,那么新任务选择跳过,排队,并发执行的策略,新任务默认选择skip策略
	Enable                bool   // 是否启用定时任务,默认 true,代表启用. 如果为 false 则该定时任务不会运行
	EnableDistributedTask bool   // 是否分布式任务,默认否,如果存在分布式任务,会只执行该定时人物
	EnableImmediatelyRun  bool   // 是否立刻执行,默认否
	EnableSeconds         bool   // 是否使用秒作解析器,默认否
	// contains filtered or unexported fields
}

Config ...

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig ...

type Container

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

Container 容器

func DefaultContainer

func DefaultContainer() *Container

DefaultContainer 默认容器

func Load

func Load(key string) *Container

Load 加载配置key

func (*Container) Build

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

Build 构建组件

type Ecron

type Ecron interface {
	standard.Component
}

Ecron ...

type Entry

type Entry = cron.Entry

Entry ...

type EntryID

type EntryID = cron.EntryID

EntryID ...

type FuncJob

type FuncJob func(ctx context.Context) error

FuncJob ...

func (FuncJob) Name

func (f FuncJob) Name() string

Name ...

func (FuncJob) Run

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

Run ...

type Job

type Job = cron.Job

Job ...

type JobWrapper

type JobWrapper = cron.JobWrapper

JobWrapper ...

type Lock added in v0.4.2

type Lock interface {
	Lock(ctx context.Context, ttl time.Duration) error
	Unlock(ctx context.Context) error
	Refresh(ctx context.Context, ttl time.Duration) error
}

Lock ... implementations:

Redis: [ecronlock](github.com/gotomicro/eredis@v0.2.0+)

type NamedJob

type NamedJob interface {
	Run(ctx context.Context) error
	Name() string
}

NamedJob ..

type Option

type Option func(c *Container)

Option ...

func WithJob added in v0.4.2

func WithJob(job FuncJob) Option

WithJob 指定Job

func WithLocation

func WithLocation(loc *time.Location) Option

WithLocation 设置时区

func WithLock added in v0.4.2

func WithLock(lock Lock) Option

WithLock 设置分布式锁. 当 Config.EnableDistributedTask = true 时, 本 Option 必须设置

func WithParser

func WithParser(p cron.Parser) Option

WithParser 设置时间 parser

func WithSeconds

func WithSeconds() Option

WithSeconds 开启秒单位

func WithWrappers added in v0.4.2

func WithWrappers(wrappers ...JobWrapper) Option

WithWrappers 设置 JobWrapper

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