asyncjob

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGroup

func NewGroup(isConcurrent bool, jobs ...Job) *group

func NewJob

func NewJob(handler JobHandler, options ...OptionHandler) *job

Types

type Job

type Job interface {
	Name() string
	Execute(ctx context.Context) error
	Retry(ctx context.Context) error
	State() JobState
	RetryIndex() int
	SetRetryDurations(times []time.Duration)
	LastError() error
}

type JobHandler

type JobHandler func(ctx context.Context) error

type JobState

type JobState int
const (
	StateInit JobState = iota
	StateRunning
	StateFailed
	StateTimeout
	StateCompleted
	StateRetryFailed
)

type OptionHandler

type OptionHandler func(*jobConfig)

func WithName

func WithName(name string) OptionHandler

func WithRetryDurations

func WithRetryDurations(times []time.Duration) OptionHandler

Jump to

Keyboard shortcuts

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