jobworker

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoWorkerActionFunc

type DoWorkerActionFunc func(di *dig.Container, op *JobParam) error

func (DoWorkerActionFunc) YieldWorkerFunc

func (f DoWorkerActionFunc) YieldWorkerFunc(di *dig.Container, op *JobParam) IWorker

type IWorker

type IWorker interface {
	Name() string
	Op() *JobParam

	Interval() time.Duration   //运行的间隔
	Actions() []string         //支持的actions
	Params() map[string]string //支持的参数

	Start() //一直运行
	Stop()

	Run(int64) //只运行一次

	Debug() //debug用

}

type IWorkerMonitor

type IWorkerMonitor interface {
	SetMonitor(chan metrics.IndicData)
}

type JobParam

type JobParam struct {
	OpId string //op唯一标识

	Action       string
	Interval     time.Duration //执行间隔
	Statistical  bool          //是否启用统计
	ExtendParams configstc.CommonExtendParams
}

JobParam op操作参数

func (*JobParam) ExtendParamByBool

func (op *JobParam) ExtendParamByBool(k string, def ...bool) bool

ExtendParamByBool 返回extendParam指定k的bool类型值

func (*JobParam) ExtendParamByFloat

func (op *JobParam) ExtendParamByFloat(k string, def ...float64) float64

ExtendParamByFloat 返回extendParam指定k的float类型值

func (*JobParam) ExtendParamByInt

func (op *JobParam) ExtendParamByInt(k string, def ...int) int

ExtendParamByInt 返回extendParam指定k的int类型值

func (*JobParam) ExtendParamValue

func (op *JobParam) ExtendParamValue(k string, def ...string) string

type YieldWorkerFunc

type YieldWorkerFunc func(di *dig.Container, op *JobParam) IWorker //可以允许di和op为nil

Jump to

Keyboard shortcuts

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