sched

package module
v0.0.0-...-d4e6bf5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

sched

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTypeNotRegistered  = errors.New("type has not registered")
	ErrTypeBeenRegistered = errors.New("type has been registered")
)

Functions

This section is empty.

Types

type Context

type Context interface {
	Task() *Task
	Cancel() error
}

type Dispatcher

type Dispatcher interface {
	Register(typ string, handler interface{}) error
}

type Job

type Job struct {
	Id   string
	Typ  string
	Data interface{} `json:"-"`
	Raw  []byte
}

func MakeJob

func MakeJob(typ string, data interface{}) *Job

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

type Manager

type Manager interface {
	Dispatcher
	Scheduler
	Start() error
	Stop() error
}

func New

func New(db Storage, opts ...Option) Manager

type Option

type Option func(s *sched)

func WithLogger

func WithLogger(log Logger) Option

func WithTicker

func WithTicker(dur time.Duration) Option

type Scheduler

type Scheduler interface {
	Once(date time.Time, job *Job) error
	Every(period time.Duration, job *Job) error
	Cancel(job *Job) error
}

type Storage

type Storage interface {
	Query() ([]*StoreItem, error)
	Upsert(item *StoreItem) error
	Delete(item *StoreItem) error
}

type StoreItem

type StoreItem struct {
	Id   string
	Data []byte
}

type Task

type Task struct {
	*Job
	Next   time.Time
	Period time.Duration
	// contains filtered or unexported fields
}

func (*Task) Assign

func (t *Task) Assign(to interface{}) error

func (*Task) Decode

func (t *Task) Decode(data []byte) error

func (*Task) Encode

func (t *Task) Encode() ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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