Help us shape the future of Go! Take the 2026 Go Developer Survey

execution

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package execution owns queue attempt execution and settlement policy. Public job definitions, errors, deliveries, and events stay in queue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attempt

func Attempt(ctx context.Context, handler Handler, payload []byte) (error, bool)

Attempt releases its execution cancellation before settlement can begin.

func Process

func Process(
	ctx context.Context,
	delivery Delivery,
	name string,
	payload []byte,
	attempts int,
	known bool,
	unknownLimit int,
	handler Handler,
	classify Classification,
	notify Notifications,
) (error, error)

Process returns the logical execution error separately from settlement error. Shutdown retries bypass only the immediate cap; reported attempts stay intact.

Types

type Classification

type Classification struct {
	// Unknown constructs the unknown-name failure after settlement starts.
	Unknown func(string) error
	// Decode extracts an unrecoverable payload decoding failure.
	Decode func(error) (error, bool)
	// Rejected recognizes an explicit terminal rejection.
	Rejected func(error) bool
	// Permanent recognizes an explicit permanent failure.
	Permanent func(error) bool
	// RetryAfter extracts an explicit delay instead of policy backoff.
	RetryAfter func(error) (time.Duration, bool)
}

Classification binds public error identities without a parent-package cycle.

type Delivery

type Delivery interface {
	// Acknowledge requests successful completion.
	Acknowledge(context.Context) error
	// Retry requests another delivery after a lower-bound delay.
	Retry(context.Context, time.Duration) error
	// Reject requests terminal rejection.
	Reject(context.Context) error
	// Fail requests terminal failure handling.
	Fail(context.Context, error) error
}

Delivery is the settlement capability of an already admitted delivery.

type Handler

type Handler struct {
	// Attempts limits ordinary failures when the transport reports attempts.
	Attempts int
	// Backoff chooses the delay before a retry; nil delegates to the driver.
	Backoff func(int) time.Duration
	// Timeout bounds execution independently of settlement.
	Timeout time.Duration
	// Run decodes and invokes the typed application handler.
	Run func(context.Context, []byte) error
}

Handler captures the completed execution policy of one registration.

type Notifications

type Notifications struct {
	// RetryAttempts snapshots the delivery before cap and delay selection.
	RetryAttempts func() int
	// Failed runs after successful terminal failure settlement.
	Failed func(context.Context, error)
	// Rejected runs after successful rejection settlement.
	Rejected func(context.Context, error)
	// Retried runs after the transport accepts a retry.
	Retried func(context.Context, time.Duration, error)
	// TimedOut reports an expired execution deadline.
	TimedOut func(context.Context)
}

Notifications publishes only confirmed settlement outcomes, except TimedOut which reports the expired attempt before selecting its settlement.

Jump to

Keyboard shortcuts

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