scheduler

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TaskExistsErr = errors.New("task already exists")

Functions

func Exist

func Exist(name string) bool

func RegisterTask

func RegisterTask(task Task, cfg *TaskConfig) error

func RemoveTask

func RemoveTask(name string)

func Start

func Start()

func Stop

func Stop() context.Context

func TaskList

func TaskList() (tasks []string)

TaskList Snapshot

Types

type Scheduler

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

func (*Scheduler) Exist

func (s *Scheduler) Exist(name string) (exist bool)

func (*Scheduler) GetTask

func (s *Scheduler) GetTask(name string) Task

func (*Scheduler) GetTaskStatus

func (s *Scheduler) GetTaskStatus(name string) *TaskStatus

func (*Scheduler) RegisterTask

func (s *Scheduler) RegisterTask(task Task, cfg *TaskConfig) (err error)

func (*Scheduler) RemoveTask

func (s *Scheduler) RemoveTask(name string)

type Task

type Task interface {
	Name() string
	Run()
	Init(map[string]interface{}) error
}

func GetTask

func GetTask(name string) Task

type TaskConfig

type TaskConfig struct {
	Name     string                 `json:"name,omitempty"`
	Cron     string                 `json:"cron,omitempty"`
	Interval int64                  `json:"interval,omitempty"`
	Params   map[string]interface{} `json:"params,omitempty"`
}

func (*TaskConfig) AddParam

func (cfg *TaskConfig) AddParam(key string, value interface{})

func (*TaskConfig) Check

func (cfg *TaskConfig) Check() (err error)

type TaskStatus

type TaskStatus struct {
	Next time.Time `json:"next"`
	Prev time.Time `json:"prev"`
}

func GetTaskStatus

func GetTaskStatus(name string) *TaskStatus

Jump to

Keyboard shortcuts

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