Help us shape the future of Go! Take the 2026 Go Developer Survey

timeschedule

package module
v0.0.0-...-a48ed55 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

timeschedule

高性能、并发安全,定时check重试队列。适用场景,超时job重做,如消息确认重发、socket双向应答。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitTimeoutSchedule

func InitTimeoutSchedule()

func InitTimeoutScheduleV2

func InitTimeoutScheduleV2()

Types

type CacelJobID

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

type JOB

type JOB interface {
}

type Job

type Job struct {
	JobID

	OutID       int64
	Status      JobStatue
	Description string
	// contains filtered or unexported fields
}

func (*Job) GetJobDescription

func (j *Job) GetJobDescription() string

func (*Job) GetJobID

func (j *Job) GetJobID() int64

func (*Job) GetNextTime

func (j *Job) GetNextTime() time.Time

func (*Job) GetRunCount

func (j *Job) GetRunCount() int

func (*Job) GetValue

func (j *Job) GetValue(key string) (interface{}, bool)

func (*Job) SetNextRunTime

func (j *Job) SetNextRunTime(t time.Time)

func (*Job) SetValue

func (j *Job) SetValue(key string, val interface{})

type JobContext

type JobContext interface {
	SetNextRunTime(time.Time)
	GetRunCount() int
	SetValue(string, interface{})
	GetValue(string) (interface{}, bool)
	GetJobID() int64
	GetJobDescription() string
}

type JobContextV2

type JobContextV2 interface {
	SetStartTime(int64) //毫秒数
	SetStatus(int)

	SetNextRunTime(int64) //毫秒数
	GetNextRunTime() int64

	GetRunCount() int64
	SetRunCount(int64)

	// 外部id, snowflake
	SetJobID(int64)
	GetJobID() int64
}

type JobID

type JobID struct {
	ID  int64 // unix time 毫秒
	SEQ int
}

func (JobID) LessThan

func (j JobID) LessThan(other skiplist.Ordered) bool

type JobStatue

type JobStatue int
const (
	WAITING JobStatue
	RUNING
	DONE
	CANCEL
)

type JobV2

type JobV2 struct {
	JobContextV2
	InnerID JobID
	// contains filtered or unexported fields
}

type TIMESCHED

type TIMESCHED interface {
	AddCheckJob(time.Duration, func() bool) int64
	RemoveCheckJob(int64)
}

type TimeoutSchedule

type TimeoutSchedule struct {
	*skiplist.SkipList
	*snowflake.Node

	UpdataCb func(*Job) // 注意这个回调函数长时间阻塞可能会导致整个job调度停滞
	// contains filtered or unexported fields
}
var TimeoutScheduleIns *TimeoutSchedule

func (*TimeoutSchedule) AddCheckJob

func (ts *TimeoutSchedule) AddCheckJob(d time.Duration, cb func(jc JobContext) bool) int64

func (*TimeoutSchedule) AddCheckJobWithData

func (ts *TimeoutSchedule) AddCheckJobWithData(t time.Time, cb func(jc JobContext) bool, desc string, data map[string]interface{}) int64

func (*TimeoutSchedule) AddCheckJobWithTime

func (ts *TimeoutSchedule) AddCheckJobWithTime(t time.Time, cb func(jc JobContext) bool) int64

func (*TimeoutSchedule) AddCheckJobWithTimeV2

func (ts *TimeoutSchedule) AddCheckJobWithTimeV2(t time.Time, cb func(jc JobContext) bool, desc string) int64

func (*TimeoutSchedule) RemoveCheckJob

func (ts *TimeoutSchedule) RemoveCheckJob(jid int64)

func (*TimeoutSchedule) Start

func (ts *TimeoutSchedule) Start()

type TimeoutScheduleV2

type TimeoutScheduleV2 struct {
	*skiplist.SkipList
	*snowflake.Node

	UpdataCb func(JobContextV2) // 注意这个回调函数长时间阻塞可能会导致整个job调度停滞
	// contains filtered or unexported fields
}
var TimeoutScheduleInsV2 *TimeoutScheduleV2

func (*TimeoutScheduleV2) AddCheckJob

func (ts *TimeoutScheduleV2) AddCheckJob(jc JobContextV2, cb func(jc JobContextV2) bool) int64

func (*TimeoutScheduleV2) RemoveCheckJob

func (ts *TimeoutScheduleV2) RemoveCheckJob(jid int64)

func (*TimeoutScheduleV2) Start

func (ts *TimeoutScheduleV2) Start()

Jump to

Keyboard shortcuts

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