sdk

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewExecutor

func NewExecutor(ctx context.Context, options ...Option) (err error)

NewExecutor 创建执行器

Types

type Executor

type Executor interface {
	Run() (err error)
	// AddRegTask 本地注册
	AddRegTask(handler string, task FuncTask)
	// RegTask 服务器注册
	RegTask() (err error)
	// GetTaskInstance 获取调度任务实例
	GetTaskInstance() common.RunReq
	// RunTask 运行任务
	RunTask(req common.RunReq) common.CallElement
}

Executor 执行器

func GetExecutor

func GetExecutor() Executor

GetExecutor 获取执行器实例

type FuncTask

type FuncTask func(param common.RunReq) (code int, msg string)

FuncTask 任务执行函数

type ListTask

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

ListTask 任务列表 [JobID]执行函数,并行执行时[+LogID]

func (*ListTask) Del

func (t *ListTask) Del(key string)

Del 设置数据

func (*ListTask) Exists

func (t *ListTask) Exists(key string) bool

Exists Key是否存在

func (*ListTask) Get

func (t *ListTask) Get(key string) *Task

Get 获取数据

func (*ListTask) GetAll

func (t *ListTask) GetAll() map[string]*Task

GetAll 获取所有数据

func (*ListTask) GetKeys

func (t *ListTask) GetKeys() []string

GetKeys 获取keys

func (*ListTask) Len

func (t *ListTask) Len() int

Len 长度

func (*ListTask) Set

func (t *ListTask) Set(key string, val *Task)

Set 设置数据

type Option

type Option func(e *executor)

func WithCancelReg

func WithCancelReg(cancel bool) Option

WithCancelReg 是否取消-自动注册任务

func WithClientId

func WithClientId(clientId string) Option

WithClientId 客户端ID/应用模块ID

func WithDelay

func WithDelay(delay time.Duration) Option

WithDelay 延时获取任务实例。默认1s。

func WithHost

func WithHost(host string) Option

WithHost 调度服务地址

func WithHttpTimeout

func WithHttpTimeout(timeout time.Duration) Option

WithHttpTimeout 超时时间

func WithTask

func WithTask(handler string, task FuncTask) Option

WithTask 本地注册任务

type Task

type Task struct {
	Id    string
	Name  string
	Param common.RunReq

	StartTime int64
	EndTime   int64
	// contains filtered or unexported fields
}

Task 任务

func (*Task) Info

func (t *Task) Info() string

Info 任务信息

func (*Task) Run

func (t *Task) Run() common.CallElement

Run 运行任务

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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