basetype

package
v0.0.0-...-ed4fdcb Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RetSysError int = iota - 1
	RetOk
	RetInvalidParam
	RetTypeInvalid
	RetStartTimeInvalid
	RetCallBackInvalid
	RetIdAndNameInvalid
)
View Source
const (
	MethodRpc = "RPC"
)

Variables

View Source
var (
	ErrSysError             = errors.New("system error")
	ErrInvalidArgument      = errors.New("invalid argument")
	ErrTaskTypeInvalid      = errors.New("task type is invalid")
	ErrTaskStartTimeInvalid = errors.New("task starttime is invalid")
	ErrTaskCallBackInvalid  = errors.New("task url or methon is invalid")
	ErrIdAndNameInvalid     = errors.New("id and name is invalid")
)
View Source
var NoBodyMethods map[string]bool = map[string]bool{
	"GET":     true,
	"HEAD":    true,
	"DELETE":  true,
	"OPTIONS": true,
}

Functions

This section is empty.

Types

type CallBackArg

type CallBackArg struct {
	NodeInfo *Node
}

Timer Func call back arg

type ContentType

type ContentType int
const (
	ContentJson ContentType = iota + 1
	ContentForm
)

type EnableType

type EnableType int
const (
	Enable EnableType = iota + 1
	Disable
)

type Node

type Node struct {
	// Unique Id to identify, this is task id.
	Id          int64
	Name        string
	RunningType RunType //normal, retry, doagain

	//Timer callback
	Func interface{}

	Arg interface{}

	//Current retry count
	RetryCnt int

	//Retry list second
	RetryList []uint32

	Type NodeType

	// If type is Repeate, Schedule is valid, the schedule on which this job should be run.
	Schedule Schedule

	//expire tick, real run after ExpireTick
	ExpireTick uint32
}

func (*Node) Copy

func (n *Node) Copy(s *Node)

func (*Node) IsNeedRetry

func (n *Node) IsNeedRetry() bool

func (*Node) IsNormalRun

func (n *Node) IsNormalRun() bool

func (*Node) Run

func (n *Node) Run()

type NodeType

type NodeType int
const (
	TypeSingle   NodeType = iota + 1 //单次任务, 启动时间固定, 可以为时间戳或者配置crontab
	TypeInterval                     //间隔任务, 每隔多长长时间执行
	TypeHour                         //时任务,每小时执行
	TypeDaily                        //日任务,每天的某个时间执行
	TypeMonth                        //月任务,每月的某个时间执行
	TypeYear                         //年任务,每年的某个时间执行
	TypeWeek                         //周任务,每周的某个时间执行

	InnerTypeClearLog = 100 //定期清理日志
)

type RunType

type RunType int
const (
	Normal RunType = iota + 1
	Retry
	DoAgain
)

type Schedule

type Schedule interface {
	// Return the next activation time, later than the given time.
	// Next is invoked initially, and then each time the job is run.
	Next(time.Time) time.Time
}

// Job is an interface for submitted cron jobs.

type Job interface {
	Run()
}

The Schedule describes a job's duty cycle.

type StatusType

type StatusType int
const (
	Begin StatusType = iota + 1
	Success
	Fail
)

Jump to

Keyboard shortcuts

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