service

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const HttpExecTimeout = 300

http任务执行时间不超过300秒

Variables

This section is empty.

Functions

func SendNotification

func SendNotification(taskModel models.Task, taskResult TaskResult)

发送任务结果通知

Types

type ConcurrencyQueue

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

并发队列

func (*ConcurrencyQueue) Add

func (cq *ConcurrencyQueue) Add()

func (*ConcurrencyQueue) Done

func (cq *ConcurrencyQueue) Done()

type HTTPHandler

type HTTPHandler struct{}

HTTP任务

func (*HTTPHandler) Run

func (h *HTTPHandler) Run(taskModel models.Task, taskUniqueId int64) (result string, err error)

type Handler

type Handler interface {
	Run(taskModel models.Task, taskUniqueId int64) (string, error)
}

type Instance

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

任务ID作为Key

type RPCHandler

type RPCHandler struct{}

RPC调用执行任务

func (*RPCHandler) Run

func (h *RPCHandler) Run(taskModel models.Task, taskUniqueId int64) (result string, err error)

type Task

type Task struct{}
var (
	ServiceTask Task
)

func (Task) Add

func (task Task) Add(taskModel models.Task)

添加任务

func (Task) BatchAdd

func (task Task) BatchAdd(tasks []models.Task)

批量添加任务

func (Task) Initialize

func (task Task) Initialize()

初始化任务, 从数据库取出所有任务, 添加到定时任务并运行

func (Task) NextRunTime

func (task Task) NextRunTime(taskModel models.Task) time.Time

func (Task) Remove

func (task Task) Remove(id int)

func (Task) RemoveAndAdd

func (task Task) RemoveAndAdd(taskModel models.Task)

删除任务后添加

func (Task) Run

func (task Task) Run(taskModel models.Task)

直接运行任务

func (Task) Stop

func (task Task) Stop(ip string, port int, id int64)

停止运行中的任务

func (Task) WaitAndExit

func (task Task) WaitAndExit()

等待所有任务结束后退出

type TaskCount

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

任务计数

func (*TaskCount) Add

func (tc *TaskCount) Add()

func (*TaskCount) Done

func (tc *TaskCount) Done()

func (*TaskCount) Exit

func (tc *TaskCount) Exit()

func (*TaskCount) Wait

func (tc *TaskCount) Wait()

type TaskResult

type TaskResult struct {
	Result     string
	Err        error
	RetryTimes int8
}

Jump to

Keyboard shortcuts

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