workers

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyWorker is returned by New calls
	// when workers name is already exists.
	ErrAlreadyWorker = errors.New("worker name must be unique")

	// ErrWrongOptions is returned by New calls
	// when parameter Options.Schedule is NIL or Options.Handler is NIL.
	ErrWrongOptions = errors.New("wrong options")
)

Functions

func New

func New(opts Options) (err error)

New returns an error if cannot create new worker

func Start

func Start()

Start all workers.

func Stop

func Stop()

Stop all workers.

func Wait

func Wait()

Wait blocks until all workers will be stopped.

Types

type Options

type Options struct {
	Name     string
	Schedule Schedule
	Handler  func()
}

Options structure for creation new worker.

type Schedule

type Schedule = cron.Schedule

Schedule describes a job's duty cycle.

Return the next activation time, later than the given time. Next is invoked initially, and then each time the job is run.

func Every

func Every(duration time.Duration) Schedule

Every returns a crontab Schedule that activates once every duration. Delays of less than a second are not supported (will round up to 1 second). Any fields less than a Second are truncated.

func Parse

func Parse(spec string) (Schedule, error)

Parse returns a new crontab schedule representing the given spec. It returns a descriptive error if the spec is not valid.

It accepts

  • Full crontab specs, e.g. "* * * * * ?"
  • Descriptors, e.g. "@midnight", "@every 1h30m"

Jump to

Keyboard shortcuts

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