timerworker

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilWorker = errors.New("worker is nil")
	ErrNilLogger = errors.New("logger is nil")
	ErrHadRunned = errors.New("timer had runned")
	ErrNotRun    = errors.New("timer not run")
)

Functions

This section is empty.

Types

type Timer

type Timer struct {
	Duration time.Duration

	Logger log.FieldsLogger
	// contains filtered or unexported fields
}

func NewTimer

func NewTimer(duration time.Duration, worker Worker, logger log.FieldsLogger) (*Timer, error)

func (*Timer) Run

func (t *Timer) Run(ctx context.Context, isblock, skipfirst bool) error

func (*Timer) Stop

func (t *Timer) Stop() error

type Worker

type Worker interface {
	Do(ctx context.Context, logger log.FieldsLogger) (end bool)
	Done(ctx context.Context, logger log.FieldsLogger)
}

Jump to

Keyboard shortcuts

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