idempotencywebhook

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 idempotencywebhook provides provider-delivery deduplication for webhook messages with bounded payload fingerprints and durable ownership.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInProgress reports another active delivery owner.
	ErrInProgress = idempotencyqueue.ErrInProgress
	// ErrConflict reports reuse of a provider delivery ID for another payload.
	ErrConflict = idempotencyqueue.ErrConflict
	// ErrTerminalFailure reports a deliberately persisted permanent failure.
	ErrTerminalFailure = idempotencyqueue.ErrTerminalFailure
)

Functions

func Wrap

func Wrap[D Delivery](
	processor *Processor,
	next func(context.Context, D) error,
) func(context.Context, D) error

Wrap preserves the provider-specific delivery type used by a webhook router.

Types

type Delivery

type Delivery interface {
	Payload() []byte
}

Delivery is the structural payload contract expected from webhook messages.

type FingerprintFunc

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

FingerprintFunc computes canonical event identity.

type Handler

type Handler func(context.Context, Delivery) error

Handler processes one elected provider delivery.

type KeyFunc

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

KeyFunc constructs a provider, endpoint, tenant, and delivery-scoped key.

type Options

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

Options configures durable webhook delivery ownership.

type Processor

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

Processor deduplicates completed provider deliveries.

func New

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

New validates options and constructs a webhook processor.

func (*Processor) Handle

func (p *Processor) Handle(ctx context.Context, delivery Delivery, handler Handler) error

Handle executes handler once and deduplicates completed redelivery.

Jump to

Keyboard shortcuts

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