nano: github.com/lonnng/nano/scheduler Index | Files

package scheduler

import "github.com/lonnng/nano/scheduler"

Index

Package Files

scheduler.go timer.go

func Close Uses

func Close()

func PushTask Uses

func PushTask(task Task)

func Sched Uses

func Sched()

type Hook Uses

type Hook func()

type LocalScheduler Uses

type LocalScheduler interface {
    Schedule(Task)
}

LocalScheduler schedules task to a customized goroutine

type Task Uses

type Task func()

type Timer Uses

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

Timer represents a cron job

func NewAfterTimer Uses

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

NewAfterTimer returns a new Timer containing a function that will be called after duration that specified by the duration argument. The duration d must be greater than zero; if not, NewAfterTimer will panic. Stop the timer to release associated resources.

func NewCondTimer Uses

func NewCondTimer(condition TimerCondition, fn TimerFunc) *Timer

NewCondTimer returns a new Timer containing a function that will be called when condition satisfied that specified by the condition argument. The duration d must be greater than zero; if not, NewCondTimer will panic. Stop the timer to release associated resources.

func NewCountTimer Uses

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

NewCountTimer returns a new Timer containing a function that will be called with a period specified by the duration argument. After count times, timer will be stopped automatically, It adjusts the intervals for slow receivers. The duration d must be greater than zero; if not, NewCountTimer will panic. Stop the timer to release associated resources.

func NewTimer Uses

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

NewTimer returns a new Timer containing a function that will be called with a period specified by the duration argument. It adjusts the intervals for slow receivers. The duration d must be greater than zero; if not, NewTimer will panic. Stop the timer to release associated resources.

func (*Timer) ID Uses

func (t *Timer) ID() int64

ID returns id of current timer

func (*Timer) Stop Uses

func (t *Timer) Stop()

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

type TimerCondition Uses

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

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

type TimerFunc Uses

type TimerFunc func()

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

Package scheduler imports 9 packages (graph). Updated 2019-07-05. Refresh now. Tools for package owners.