task

package module
v2.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: MIT Imports: 11 Imported by: 1

README

task

timed task

Go Report Card GoDoc GitHub license

Usage

API Documentation

License

Pouch is licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = NewTask(runtime.NumCPU() + 2)

Default task instance

View Source
var TaskExit = time.Time{}

TaskExit exit time

Functions

func Cancel

func Cancel(n *Node)

Cancel the task for this node

func CancelAll

func CancelAll()

CancelAll Cancel all tasks

func Join

func Join()

Join Waiting for all tasks to finish

func Len

func Len() int

Len returns the number of task

func PeriodicCrontab

func PeriodicCrontab(crontab string) func() time.Time

PeriodicCrontab this is a crontab style timer six columns mean:

second:0-59
minute:0-59
hour:1-23
day:1-31
month:1-12
week:0-6(0 means Sunday)

SetCron some signals:

*: any time
,:  separate signal

   -:duration

/n : do as n times of time duration

///////////////////////////////////////////////////////

0/30 * * * * *                        every 30s
0 43 21 * * *                         21:43
0 15 05 * * *                        05:15
0 0 17 * * *                          17:00
0 0 17 * * 1                           17:00 in every Monday
0 0,10 17 * * 0,2,3                   17:00 and 17:10 in every Sunday, Tuesday and Wednesday
0 0-10 17 1 * *                       17:00 to 17:10 in 1 min duration each time on the first day of month
0 0 0 1,15 * 1                        0:00 on the 1st day and 15th day of month
0 42 4 1 * *                         4:42 on the 1st day of month
0 0 21 * * 1-6                       21:00 from Monday to Saturday
0 0,10,20,30,40,50 * * * *            every 10 min duration
0 */10 * * * *                     every 10 min duration
0 * 1 * * *                       1:00 to 1:59 in 1 min duration each time
0 0 1 * * *                       1:00
0 0 */1 * * *                      0 min of hour in 1 hour duration
0 0 * * * *                       0 min of hour in 1 hour duration
0 2 8-20/3 * * *                   8:02, 11:02, 14:02, 17:02, 20:02
0 30 5 1,15 * *                    5:30 on the 1st day and 15th day of month

func PeriodicEveryDay

func PeriodicEveryDay(tim string) func() time.Time

PeriodicEveryDay is a fixed time of day

15:04:05 of 15:04:05.999999999 This time of day
2006-01-02 15:04:05.999999999 This time of day from a certain date

func PeriodicInterval

func PeriodicInterval(offset time.Duration, interval time.Duration) func() time.Time

PeriodicInterval is generates a fixed interval time function, unlimited number of times

func PeriodicIntervalCount

func PeriodicIntervalCount(start time.Time, interval time.Duration, count int) func() time.Time

PeriodicIntervalCount is generates a fixed interval time function

func PeriodicMerge

func PeriodicMerge(fs ...func() time.Time) func() time.Time

func PeriodicTiming

func PeriodicTiming(ts ...time.Time) func() time.Time

PeriodicTiming is multiple time for execution

func Print

func Print()

Print task list

Types

type Node

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

Node is store tasks

func Add

func Add(tim time.Time, task func()) (n *Node)

Add The specified time to execute

func AddPeriodic

func AddPeriodic(perfunc func() time.Time, task func()) (n *Node)

AddPeriodic Periodic execution

func List

func List() []*Node

List returns task list

func (*Node) Func

func (no *Node) Func() func()

Func returns tasks function

func (*Node) Less

func (no *Node) Less(i llrb.Item) bool

Less returns compare the time with another node

func (*Node) Name

func (no *Node) Name() string

Name returns the node name

func (*Node) Next

func (no *Node) Next() time.Time

Next returns next time

func (*Node) SetName

func (no *Node) SetName(name string)

SetName sets node name

func (*Node) String

func (no *Node) String() string

String returns strings

type Schedule

type Schedule struct {
	Second uint64
	Minute uint64
	Hour   uint64
	Day    uint64
	Month  uint64
	Week   uint64
}

Schedule time taks schedule

func (*Schedule) Next

func (s *Schedule) Next(t time.Time) time.Time

Next set schedule to next time

type Spacing

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

Spacing is interval to perform

func NewSpacing

func NewSpacing(d time.Duration, fun func()) *Spacing

NewSpacing create a fixed interval

func NewSpacingPeriodic

func NewSpacingPeriodic(perfunc func() time.Time, fun func()) *Spacing

NewSpacingPeriodic create a compute interval

func (*Spacing) On

func (s *Spacing) On()

On is trying to perform

type Task

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

Task defined task sets

func NewTask

func NewTask(i int) *Task

NewTask create a new task that specifies the maximum number of fork

func (*Task) Add

func (t *Task) Add(tim time.Time, task func()) *Node

Add The specified time to execute

func (*Task) AddPeriodic

func (t *Task) AddPeriodic(perfunc func() time.Time, task func()) (n *Node)

AddPeriodic Periodic execution

func (*Task) Cancel

func (t *Task) Cancel(n *Node)

Cancel the task for this node

func (*Task) CancelAll

func (t *Task) CancelAll()

CancelAll Cancel all tasks

func (*Task) Join

func (t *Task) Join()

Join Waiting for all tasks to finish

func (*Task) Len

func (t *Task) Len() int

Len returns the number of task

func (*Task) List

func (t *Task) List() []*Node

List returns task list

func (*Task) Print

func (t *Task) Print()

Print task list

Jump to

Keyboard shortcuts

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