ticker

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scheduler

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

func NewScheduler

func NewScheduler() *Scheduler

func (*Scheduler) Every

func (s *Scheduler) Every(interval ...int) *TaskConfig

Every begins configuring a task. Supply zero or one intervals. No intervals will be counted as 1

func (*Scheduler) Once

func (s *Scheduler) Once() *TaskConfig

Once sets the task to run only once.

func (*Scheduler) Start

func (s *Scheduler) Start()

func (*Scheduler) Stop

func (s *Scheduler) Stop()

type Task

type Task struct {
	Payloads []interface{}
	Elapsed  time.Duration
	// contains filtered or unexported fields
}

Task is passed to task handlers and contains the payload

func (*Task) Stop

func (t *Task) Stop()

type TaskConfig

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

func (*TaskConfig) After

func (tc *TaskConfig) After(interval time.Duration) *TaskConfig

After starts the task after the specified duration. Short hand for From(time.Now().Add(interval))

func (*TaskConfig) At

func (tc *TaskConfig) At(hour, minute int) *TaskConfig

At sets the time of day to run the task.

func (*TaskConfig) Day

func (tc *TaskConfig) Day() *TaskConfig

Day sets the interval to days.

func (*TaskConfig) Days

func (tc *TaskConfig) Days() *TaskConfig

Days is same as Day.

func (*TaskConfig) Do

func (tc *TaskConfig) Do(f TaskFunc, payloads ...interface{}) (s *Scheduler)

Do start the task with the supplied payload in a new goroutine.

func (*TaskConfig) Friday

func (tc *TaskConfig) Friday() *TaskConfig

Friday sets the unit to weeks and only runs on Fridays.

func (*TaskConfig) From

func (tc *TaskConfig) From(from time.Time) *TaskConfig

From sets the start time of the task.

func (*TaskConfig) Hour

func (tc *TaskConfig) Hour() *TaskConfig

Hour sets the interval to hours.

func (*TaskConfig) Hours

func (tc *TaskConfig) Hours() *TaskConfig

Hours is same as Hour.

func (*TaskConfig) Minute

func (tc *TaskConfig) Minute() *TaskConfig

Minute sets the interval to minutes.

func (*TaskConfig) Minutes

func (tc *TaskConfig) Minutes() *TaskConfig

Minutes is same as Minute.

func (*TaskConfig) Monday

func (tc *TaskConfig) Monday() *TaskConfig

Monday sets the unit to weeks and only runs on Mondays.

func (*TaskConfig) Saturday

func (tc *TaskConfig) Saturday() *TaskConfig

Saturday sets the unit to weeks and only runs on Saturdays.

func (*TaskConfig) Second

func (tc *TaskConfig) Second() *TaskConfig

Second sets the interval to seconds.

func (*TaskConfig) Seconds

func (tc *TaskConfig) Seconds() *TaskConfig

Seconds is same as Second.

func (*TaskConfig) Sunday

func (tc *TaskConfig) Sunday() *TaskConfig

Sunday sets the unit to weeks and only runs on Sundays.

func (*TaskConfig) Thursday

func (tc *TaskConfig) Thursday() *TaskConfig

Thursday sets the unit to weeks and only runs on Thursdays.

func (*TaskConfig) To

func (tc *TaskConfig) To(to time.Time) *TaskConfig

To sets the end time of the task.

func (*TaskConfig) Tuesday

func (tc *TaskConfig) Tuesday() *TaskConfig

Tuesday sets the unit to weeks and only runs on Tuesdays.

func (*TaskConfig) Wednesday

func (tc *TaskConfig) Wednesday() *TaskConfig

Wednesday sets the unit to weeks and only runs on Wednesdays.

func (*TaskConfig) Week

func (tc *TaskConfig) Week() *TaskConfig

Week sets the interval to weeks.

func (*TaskConfig) Weeks

func (tc *TaskConfig) Weeks() *TaskConfig

Weeks is same as Week.

type TaskFunc

type TaskFunc func(*Task) error

Source Files

  • scheduler.go
  • task.go

Jump to

Keyboard shortcuts

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