executor

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package executor runs one attempt of a job and maps the result to a completion.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoWorker = job.ErrNoWorker

Functions

This section is empty.

Types

type Attempt

type Attempt struct {
	Row *job.Row
	// contains filtered or unexported fields
}

func AttemptFromContext

func AttemptFromContext(ctx context.Context) *Attempt

func (*Attempt) CompletedInTx

func (a *Attempt) CompletedInTx() bool

func (*Attempt) MarkCompletedInTx

func (a *Attempt) MarkCompletedInTx()

type Config

type Config struct {
	Lookup         func(kind string) (Handler, bool)
	DefaultTimeout time.Duration
	DefaultRetry   RetryFunc
	HandleError    func(ctx context.Context, row *job.Row, err error) *job.Override
	HandlePanic    func(ctx context.Context, row *job.Row, value any, trace string) *job.Override
	Clock          clock.Clock
	Logger         *slog.Logger
	Observe        func(row *job.Row, outcome string, d time.Duration)
}

type Executor

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

Executor runs a job with a timeout and panic recovery and maps the result to a completion.

func New

func New(cfg Config) (*Executor, error)

New validates cfg and applies defaults.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, row *job.Row) (c job.Completion, skip bool)

Execute runs one attempt of row and returns the completion to write.

type Handler

type Handler struct {
	Work    WorkFunc
	Timeout time.Duration
	Retry   RetryFunc
}

type RetryFunc

type RetryFunc func(row *job.Row, now time.Time) time.Time

RetryFunc returns the next run time of a job that failed at now.

type WorkFunc

type WorkFunc func(ctx context.Context, row *job.Row) error

WorkFunc runs one attempt of a job.

Jump to

Keyboard shortcuts

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