idempotencycommand

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 idempotencycommand provides durable named command and source-record import execution with bounded result replay.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInProgress reports an unexpired owner for the source record.
	ErrInProgress = errors.New("idempotencycommand: operation in progress")
	// ErrConflict reports reuse of a source identity for different input.
	ErrConflict = errors.New("idempotencycommand: source fingerprint conflict")
	// ErrTerminalFailure reports a deliberately persisted permanent failure.
	ErrTerminalFailure = errors.New("idempotencycommand: operation terminally failed")
)

Functions

This section is empty.

Types

type Handler

type Handler func(context.Context) ([]byte, map[string]string, error)

Handler executes one elected source-record owner and returns replay data.

type Options

type Options struct {
	Service           *idempotency.Service
	Lease             time.Duration
	TransitionTimeout time.Duration
}

Options configures command leases and failed-handler cleanup.

type Request

type Request struct {
	Namespace   string
	Tenant      string
	Name        string
	Caller      string
	SourceID    string
	Fingerprint idempotency.Fingerprint
}

Request identifies a named command or one record in an import source.

type Result

type Result struct {
	Outcome  idempotency.Outcome
	Result   []byte
	Metadata map[string]string
	Replayed bool
}

Result reports the semantic outcome and bounded replay data.

type Runner

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

Runner durably executes named commands and source-record imports.

func New

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

New validates options and constructs a command runner.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, request Request, handler Handler) (Result, error)

Run executes handler only for a newly acquired or taken-over source record.

Jump to

Keyboard shortcuts

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