scheduler

package
v1.1.92 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Infinite = -1
)

Variables

This section is empty.

Functions

func Close

func Close()

func NewScheduler added in v1.1.13

func NewScheduler() *scheduler

NewScheduler creates a new TimerScheduler

func PushTask

func PushTask(task Task)

func Schedule

func Schedule(_ *session.Session, _ interface{}, task Task)

Types

type Context added in v1.1.71

type Context struct {
	ServiceName string
	HandlerName string
	Data        interface{}
}

type ScheduleFunc added in v1.1.44

type ScheduleFunc func(*session.Session, *Context, Task)

type Scheduler added in v1.1.13

type Scheduler interface {
	TimerManager
	Schedule(*session.Session, *Context, Task)
	PushTask(task Task)
	Digest()
	Close()
}

func Global added in v1.1.41

func Global() Scheduler

type Task

type Task func()

Task is the unit to be scheduled

type Timer

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

Timer represents a cron job

func NewAfterTimer

func NewAfterTimer(duration time.Duration, fn TimerFunc) *Timer

func NewCondTimer

func NewCondTimer(condition TimerCondition, fn TimerFunc) *Timer

func NewCountTimer

func NewCountTimer(interval time.Duration, count int, fn TimerFunc) *Timer

func NewTimer

func NewTimer(interval time.Duration, fn TimerFunc) *Timer

func (*Timer) ID

func (t *Timer) ID() int64

ID returns id of current timer

func (*Timer) Stop

func (t *Timer) Stop()

Stop turns off a timer. After Stop, fn will not be called forever

type TimerCondition

type TimerCondition interface {
	Check(now time.Time) bool
}

TimerCondition represents a checker that returns true when cron job needs to execute

type TimerFunc

type TimerFunc func()

TimerFunc represents a function which will be called periodically in main logic gorontine.

type TimerManager added in v1.0.1

type TimerManager interface {
	NewCountTimer(interval time.Duration, count int, fn TimerFunc) *Timer
	NewAfterTimer(duration time.Duration, fn TimerFunc) *Timer
	NewCondTimer(condition TimerCondition, fn TimerFunc) *Timer
	NewTimer(interval time.Duration, fn TimerFunc) *Timer
	TaskChan() <-chan Task
	CloseTimer()
}

func NewTimerManager added in v1.0.1

func NewTimerManager() TimerManager

Jump to

Keyboard shortcuts

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