service

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const HttpExecTimeout = 300

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

Variables

View Source
var Cron *cron.Cron

定时任务调度管理器

Functions

func SendNotification

func SendNotification(taskModel models.Task, taskResult TaskResult)

发送任务结果通知

Types

type HTTPHandler

type HTTPHandler struct{}

HTTP任务

func (*HTTPHandler) Run

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

type Handler

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

type Instance

type Instance struct {
	Status map[int]bool
	sync.RWMutex
}

任务ID作为Key

type RPCHandler added in v1.2.1

type RPCHandler struct{}

RPC调用执行任务

func (*RPCHandler) Run added in v1.2.1

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

type Task

type Task struct{}

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) Run

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

直接运行任务

func (*Task) StopAll

func (task *Task) StopAll()

停止所有任务

type TaskCount

type TaskCount struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

任务计数

var TaskNum TaskCount

任务计数-正在运行中的任务

func (*TaskCount) Add

func (c *TaskCount) Add()

func (*TaskCount) Done

func (c *TaskCount) Done()

func (*TaskCount) Num

func (c *TaskCount) Num() int

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