idempotencyqueue

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package idempotencyqueue provides durable consumer ownership and redelivery deduplication for messages exposing a Payload method.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInProgress tells a broker to retry after another owner's lease.
	ErrInProgress = errors.New("idempotencyqueue: delivery in progress")
	// ErrConflict identifies reuse of a delivery key for a different payload.
	ErrConflict = errors.New("idempotencyqueue: delivery fingerprint conflict")
	// ErrTerminalFailure identifies a previously recorded permanent failure.
	ErrTerminalFailure = errors.New("idempotencyqueue: delivery terminally failed")
)

Functions

func Wrap

func Wrap[M Message](
	middleware *Middleware,
	next func(context.Context, M) error,
) func(context.Context, M) error

Wrap preserves the concrete message type expected by queue WithFn.

Types

type FingerprintFunc

type FingerprintFunc func(Message) (idempotency.Fingerprint, error)

FingerprintFunc computes canonical payload identity.

type Handler

type Handler func(context.Context, Message) error

Handler processes one elected delivery owner.

type KeyFunc

type KeyFunc func(context.Context, Message) (idempotency.Key, error)

KeyFunc creates the consumer and delivery-scoped semantic key.

type Message

type Message interface {
	Payload() []byte
}

Message is satisfied by queue core.TaskMessage and similar deliveries.

type Middleware

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

Middleware deduplicates completed deliveries and owns retry transitions.

func New

func New(options Options) (*Middleware, error)

New validates options and constructs queue middleware.

func (*Middleware) Handle

func (m *Middleware) Handle(ctx context.Context, message Message, handler Handler) error

Handle executes handler for an acquired delivery and completes it on success.

type Options

type Options struct {
	Service           *idempotency.Service
	Lease             time.Duration
	TransitionTimeout time.Duration
	Key               KeyFunc
	Fingerprint       FingerprintFunc
}

Options configures durable consumer ownership and cleanup.

Jump to

Keyboard shortcuts

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