jobexecutor

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2025 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ContextKeyMetadataUpdates contextKey = "river_metadata_updates"

ContextKeyMetadataUpdates is the context key for the metadata updates map stored in the context. It's exposed from this internal package solely so that it can be used in tests for JobCompleteTx.

Variables

This section is empty.

Functions

func MetadataUpdatesFromWorkContext

func MetadataUpdatesFromWorkContext(ctx context.Context) (map[string]any, bool)

MetadataUpdatesFromWorkContext returns the metadata updates stored in the work context, if any.

When run on a non-work context, it returns nil, false.

Types

type ClientRetryPolicy

type ClientRetryPolicy interface {
	NextRetry(job *rivertype.JobRow) time.Time
}

type ErrorHandler

type ErrorHandler interface {
	// HandleError is invoked in case of an error occurring in a job.
	//
	// Context is descended from the one used to start the River client that
	// worked the job.
	HandleError(ctx context.Context, job *rivertype.JobRow, err error) *ErrorHandlerResult

	// HandlePanic is invoked in case of a panic occurring in a job.
	//
	// Context is descended from the one used to start the River client that
	// worked the job.
	HandlePanic(ctx context.Context, job *rivertype.JobRow, panicVal any, trace string) *ErrorHandlerResult
}

ErrorHandler provides an interface that will be invoked in case of an error or panic occurring in the job. This is often useful for logging and exception tracking, but can also be used to customize retry behavior.

type ErrorHandlerResult

type ErrorHandlerResult struct {
	// SetCancelled can be set to true to fail the job immediately and
	// permanently. By default it'll continue to follow the configured retry
	// schedule.
	SetCancelled bool
}

type JobExecutor

type JobExecutor struct {
	baseservice.BaseService

	CancelFunc               context.CancelCauseFunc
	ClientJobTimeout         time.Duration
	Completer                jobcompleter.JobCompleter
	ClientRetryPolicy        ClientRetryPolicy
	DefaultClientRetryPolicy ClientRetryPolicy
	ErrorHandler             ErrorHandler
	HookLookupByJob          *hooklookup.JobHookLookup
	HookLookupGlobal         hooklookup.HookLookupInterface
	InformProducerDoneFunc   func(jobRow *rivertype.JobRow)
	JobRow                   *rivertype.JobRow
	MiddlewareLookupGlobal   middlewarelookup.MiddlewareLookupInterface
	SchedulerInterval        time.Duration
	WorkerMiddleware         []rivertype.WorkerMiddleware
	WorkUnit                 workunit.WorkUnit
	// contains filtered or unexported fields
}

func (*JobExecutor) Cancel

func (e *JobExecutor) Cancel()

func (*JobExecutor) Execute

func (e *JobExecutor) Execute(ctx context.Context)

Jump to

Keyboard shortcuts

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