runner

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeout timeout
	ErrTimeout = errors.New("task exec timeout")

	// ErrInterrupt interrupt signal
	ErrInterrupt = errors.New("received interrupt signal")
)

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Println(msg ...interface{})
}

Logger log interface

type Option

type Option func(r *Runner)

Option 采用func Option功能模式为Runner添加参数

func WithLogger

func WithLogger(l Logger) Option

WithLogger 设置r.logger打印日志的句柄

func WithTimeout

func WithTimeout(t time.Duration) Option

WithTimeout 设置任务超时时间

type Runner

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

Runner 声明一个runner

func New

func New(opts ...Option) *Runner

New 定义一个工厂函数创建runner 默认创建一个无超时任务的runner

func (*Runner) Add

func (r *Runner) Add(tasks ...func() error)

Add 将需要执行的任务添加到r.tasks队列中

func (*Runner) GetAllErrors

func (r *Runner) GetAllErrors() map[int]error

GetAllErrors 获取已经完成任务的error

func (*Runner) GetLastTaskId

func (r *Runner) GetLastTaskId() int

GetLastTaskId 获取最后一次完成任务id

func (*Runner) Start

func (r *Runner) Start() error

Start 开始执行所有的任务

Jump to

Keyboard shortcuts

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