coordination

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package coordination compiles bounded coordination policies into ordinary Programs. Config.Policy selects InputGate, Deadline, or FirstSuccess; Compile is their sole construction path.

InputGate declares one local Wait and returns its admitted answer directly, under AnswerSchema. Signal admission records own delivery identity; wrapping that identity in the output would make a maximum-size admitted answer exceed the output limit. Answer size and schema are fixed when the Wait opens. A new question requires a new gate identity; an ambiguous delivery must never be redirected to a replacement recipient.

Deadline dispatches one absolute deadline with SameIdentity replay. FirstSuccess admits candidate children, selects an acceptable completed result, cancels the remaining candidates, and consumes every Exit before returning the winner. A cancellation receipt confirms intent; it does not establish resource release. All candidate starts must settle before selection, and ties within one input window follow candidate declaration order.

These policies own business progress only. The Runtime owns scheduling, persistence, admission, cancellation, and drain. Completion and Exit messages must match outstanding identities; no child-wait or settlement handshake exists.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidExecutionState = run.NewClassifiedError(
		run.FailureKindContract,
		"coordination.state.invalid",
		"coordination: invalid execution state",
	)
	ErrInvalidProtocol = run.NewClassifiedError(
		run.FailureKindContract,
		"coordination.protocol.invalid",
		"coordination: invalid execution protocol",
	)
)

Execution sentinels own the Failure persisted when they reach Step. Wrapping one is the only way a Step error acquires its classification.

View Source
var ErrInvalidConfig = errors.New("coordination: invalid configuration")

ErrInvalidConfig rejects construction before execution and therefore carries no Failure classification.

Functions

func Compile added in v0.60.0

func Compile[I, O any](compiler *run.Compiler, config Config) (run.Program[I, O], error)

Types

type CandidateResult added in v0.59.0

type CandidateResult struct {
	Outcome   *run.Termination `json:"outcome,omitzero"`
	Rejection *run.Failure     `json:"rejection,omitzero"`
}

func (CandidateResult) Valid added in v0.59.0

func (c CandidateResult) Valid() bool

type Config added in v0.60.0

type Config struct {
	Name, Description string
	Policy            Policy
}

type Deadline

type Deadline struct{}

type FirstSuccess

type FirstSuccess struct {
	MaxCandidates uint32
	Accept        SuccessPredicate
	Revision      string
}

type FirstSuccessResult

type FirstSuccessResult struct {
	Winner     *uint32           `json:"winner,omitzero"`
	Candidates []CandidateResult `json:"candidates"`
}

func (FirstSuccessResult) Valid

func (f FirstSuccessResult) Valid() bool

type InputGate

type InputGate struct {
	RequestSchema, AnswerSchema jsonschema.Schema
	MaxAnswerBytes              int
}

type Policy added in v0.60.0

type Policy interface {
	// contains filtered or unexported methods
}

type SuccessPredicate

type SuccessPredicate func(context.Context, run.ChildKey, run.Termination) (bool, error)

Jump to

Keyboard shortcuts

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