schedule

package
v0.0.0-...-04e6e7a Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Size int `json:"size"` // 任务总数量

	Opts []cron.Option
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig 默认配置

func RawConfig

func RawConfig(key string) *Config

RawConfig 完整key取配置

func ScanConfig

func ScanConfig(name string) *Config

ScanConfig 名称取配置

func (*Config) Build

func (c *Config) Build() *Schedule

Build 构建任务调度

func (*Config) WithLogger

func (c *Config) WithLogger(log cron.Logger) *Config

WithLogger 设置日志组件

func (*Config) WithOptions

func (c *Config) WithOptions(ops ...cron.Option) *Config

WithOptions 设置额外参数

type Job

type Job interface {
	Cron() string
	cron.Job
}

Job 任务接口

type Logger

type Logger struct {
	Log *logger.Logger
}

func (*Logger) Error

func (l *Logger) Error(err error, msg string, keysAndValues ...interface{})

Error 错误日志

func (*Logger) Info

func (l *Logger) Info(msg string, keysAndValues ...interface{})

Info 正常日志

type Schedule

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

func (*Schedule) AddJob

func (s *Schedule) AddJob(job Job) (int, error)

AddJob 添加任务

func (*Schedule) Get

func (s *Schedule) Get(id int) cron.Entry

Get 根据id获取单个任务

func (*Schedule) List

func (s *Schedule) List() []cron.Entry

List 任务列表

func (*Schedule) RemoveJob

func (s *Schedule) RemoveJob(id int)

RemoveJob 移除任务

func (*Schedule) Run

func (s *Schedule) Run()

Run 阻塞启动

func (*Schedule) Size

func (s *Schedule) Size() int

Size 获取当前任务数量

func (*Schedule) Start

func (s *Schedule) Start()

Start 启动

func (*Schedule) Stop

func (s *Schedule) Stop()

Jump to

Keyboard shortcuts

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