jobs

package module
v0.0.0-...-6691ebf Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyStarted = errors.New("the job has already been started previously")
	ErrNotYetStarted  = errors.New("the job has never started yet")
)

Functions

This section is empty.

Types

type CompositeJob

type CompositeJob struct {
	Jobs []Job
}

func (*CompositeJob) Start

func (cj *CompositeJob) Start(ctx context.Context) error

func (*CompositeJob) Stop

func (cj *CompositeJob) Stop(ctx context.Context) error

func (*CompositeJob) Wait

func (cj *CompositeJob) Wait() error

type Job

type Job interface {
	Start(ctx context.Context) error
	StartedJob
}

func NewLoopJob

func NewLoopJob(action func(ctx context.Context)) Job

func WithPreStart

func WithPreStart(job Job, startFunc func(ctx context.Context) error) Job

type StartedJob

type StartedJob interface {
	Stop(ctx context.Context) error
	Wait() error
}

func StartLoop

func StartLoop(ctx context.Context, action func(ctx context.Context)) (StartedJob, error)

Jump to

Keyboard shortcuts

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