taskscheduler

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: MIT Imports: 8 Imported by: 0

README

taskscheduler

This task scheduler written in GO

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLog  = log.New(os.Stderr, "[ERROR]", 0)
	InfoLog = log.New(os.Stdout, "[INFO]", 0)
)
View Source
var ErrSchedulerClosed = errors.New("scheduler closed")

Functions

This section is empty.

Types

type Executor

type Executor interface {
	Do(TaskFunc) error
}

type Logger

type Logger interface {
	Infof(string, ...interface{})
	Errorf(string, ...interface{})
}

type OptionFunc

type OptionFunc func(*Scheduler)

func SetExecutor

func SetExecutor(executor Executor) OptionFunc

func SetLogger

func SetLogger(logger Logger) OptionFunc

func SetRecoverFn

func SetRecoverFn(fn RecoverFunc) OptionFunc

func SetTaskConcurrency

func SetTaskConcurrency(c int) OptionFunc

func SetTaskSize

func SetTaskSize(size int) OptionFunc

func SetTimeout

func SetTimeout(dur time.Duration) OptionFunc

type RecoverFunc

type RecoverFunc func()

type Scheduler

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

func NewScheduler

func NewScheduler(opts ...OptionFunc) *Scheduler

func (*Scheduler) AddTask

func (s *Scheduler) AddTask(fn TaskFunc) error

func (*Scheduler) Closed

func (s *Scheduler) Closed() bool

func (*Scheduler) Error

func (s *Scheduler) Error() string

func (*Scheduler) ExecutedCount

func (s *Scheduler) ExecutedCount() int64

func (*Scheduler) Finish

func (s *Scheduler) Finish()

func (*Scheduler) Start

func (s *Scheduler) Start()

func (*Scheduler) UnExecutedCount

func (s *Scheduler) UnExecutedCount() int64

func (*Scheduler) Wait

func (s *Scheduler) Wait()

type SimpleExecutor

type SimpleExecutor struct {
}

func NewSimpleExecutor

func NewSimpleExecutor() *SimpleExecutor

func (*SimpleExecutor) Do

func (se *SimpleExecutor) Do(taskFunc TaskFunc) error

type TaskFunc

type TaskFunc func() error

Jump to

Keyboard shortcuts

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