tasks

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 7, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTaskNotFound = errors.New("task not found")

Functions

func Run

func Run(ctx context.Context, task Task) (err error)

func RunWorker

func RunWorker(ctx context.Context, fn func(ctx context.Context) error, workerNum int) error

Types

type Mapper

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

func (*Mapper) Execute

func (m *Mapper) Execute(ctx context.Context) error

func (*Mapper) Find

func (m *Mapper) Find(name string) Task

func (*Mapper) Register

func (m *Mapper) Register(task Task) error

Register 注册

func (*Mapper) Run

func (m *Mapper) Run(ctx context.Context, name string) error

func (*Mapper) Tasks

func (m *Mapper) Tasks() map[string]Task

type Task

type Task interface {
	Name() string
	FlagSet(fg *flag.FlagSet)
	Run(ctx context.Context) error
	TearDown(err error)
}

Task 任务

type TaskHelper

type TaskHelper struct {
}

TaskHelper task 的一些辅助功能

func (*TaskHelper) ConfDir

func (h *TaskHelper) ConfDir() string

ConfDir 返回任务的配置目录

func (*TaskHelper) DataDir

func (h *TaskHelper) DataDir() string

func (*TaskHelper) ReadConf

func (h *TaskHelper) ReadConf(name string, value any) error

ReadConf 从 task 自己的目录里解析配置

func (*TaskHelper) TmpDir

func (h *TaskHelper) TmpDir() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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