kernel

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCreated  = 1
	StatusRunning  = 2
	StatusRetrying = 3

	StatusFailed = 10

	StatusSuccess = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context added in v0.1.7

type Context struct {
	context.Context
}

func NewContext added in v0.1.7

func NewContext(ctx context.Context) *Context

func (*Context) Put added in v0.2.3

func (c *Context) Put(key any, value any)

func (*Context) Runtime added in v0.1.7

func (c *Context) Runtime(runtime time.Time)

type Executor added in v0.1.5

type Executor interface {
	// Execute 执行任务
	Execute(ctx *Context, target uint64, times uint32) error
}

type Schedule added in v0.1.5

type Schedule interface {
	// Id 任务标识,如果不提供将自动生成
	Id() uint64

	// Target 目标
	Target() uint64

	// Timeout 任务超时时间
	Timeout() time.Duration

	// Type 类型
	Type() Type

	// Subtype 子类型
	Subtype() Type

	// Maximum 最大重试次数
	Maximum() uint32

	// Data 数据
	Data() map[string]any

	// Next 下一个可被执行的时间
	Next() time.Time
}

type Selector added in v0.1.5

type Selector interface {
	// Select 选择不同的执行器执行任务
	Select(Task) (Executor, error)
}

type Status

type Status uint8

type Task added in v0.1.5

type Task interface {
	Schedule

	// Times 当然运行次数
	Times() uint32
}

type Tasker added in v0.1.5

type Tasker interface {
	// Start 启动
	Start(ctx context.Context) error

	// Add 添加
	Add(schedule Schedule, schedules ...Schedule) error

	// Remove 删除
	Remove(schedule Schedule) error

	// Running 运行中
	Running(id uint64, status Status, times uint32) error

	// Update 修改
	Update(id uint64, status Status, runtime time.Time) error

	// Pop 取出任务并执行
	Pop() Task

	// Archive 存档
	Archive(task Task) error

	// Failed 执行错误
	Failed(task Task) error

	// Stop 停止
	Stop(ctx context.Context) error
}

type Type

type Type uint16
const (
	TypeCron Type = iota + 1
	TypeFixed
	TypeRate
	TypeComputable
	TypeOnce
)

Jump to

Keyboard shortcuts

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