invocation

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package invocation defines metadata that must cross every external effect boundary.

Index

Constants

View Source
const (
	HeaderExecutionID    = "X-Effectus-Execution-ID"
	HeaderSagaID         = "X-Effectus-Saga-ID"
	HeaderEffectID       = "X-Effectus-Effect-ID"
	HeaderAttempt        = "X-Effectus-Attempt"
	HeaderDirection      = "X-Effectus-Direction"
	HeaderArgumentHash   = "X-Effectus-Argument-Hash"
	HeaderContractHash   = "X-Effectus-Contract-Hash"
	HeaderFencingGrants  = "X-Effectus-Fencing-Grants"
	HeaderDeadline       = "X-Effectus-Deadline"
	HeaderOutcome        = "X-Effectus-Outcome"
	HeaderIdempotencyKey = "Idempotency-Key"
)

Variables

This section is empty.

Functions

func ValidateOutcome

func ValidateOutcome(outcome Outcome) error

ValidateOutcome rejects incomplete or contradictory classifications.

Types

type Context

type Context struct {
	RequestID     string         `json:"request_id"`
	ExecutionID   string         `json:"execution_id"`
	Saga          Saga           `json:"saga"`
	FencingGrants []FencingGrant `json:"fencing_grants,omitempty"`
	Deadline      time.Time      `json:"deadline"`
}

Context contains transport-neutral invocation metadata.

type Direction

type Direction string

Direction distinguishes a forward mutation from its compensation.

const (
	DirectionForward      Direction = "forward"
	DirectionCompensation Direction = "compensation"
)

type Executor

type Executor interface {
	Invoke(context.Context, Request) Outcome
}

Executor accepts stable identity and fencing metadata as part of its API.

type FencingGrant

type FencingGrant struct {
	Authority string `json:"authority"`
	Resource  string `json:"resource"`
	Token     uint64 `json:"token"`
}

FencingGrant is immutable system metadata. Adapters must not source these values from caller arguments or caller headers.

type FencingStatus

type FencingStatus string

FencingStatus describes observation without claiming destination enforcement.

const (
	FencingNotRequested  FencingStatus = "not_requested"
	FencingLocalLockOnly FencingStatus = "local_lock_only"
	FencingPropagated    FencingStatus = "propagated"
	FencingAcknowledged  FencingStatus = "acknowledged"
	FencingStaleRejected FencingStatus = "stale_rejected"
)

type HTTPExecutor

type HTTPExecutor struct {
	URL              string
	Method           string
	Headers          map[string]string
	Client           *http.Client
	MaxResponseBytes int64
}

HTTPExecutor sends one invocation without an internal retry loop.

func NewHTTPExecutor

func NewHTTPExecutor(executor HTTPExecutor) (*HTTPExecutor, error)

func (*HTTPExecutor) Invoke

func (executor *HTTPExecutor) Invoke(ctx context.Context, request Request) Outcome

type Outcome

type Outcome struct {
	Class  OutcomeClass
	Result any
	Err    error
}

Outcome is the executor's explicit result classification.

type OutcomeClass

type OutcomeClass string

OutcomeClass states whether the destination can know that a mutation committed.

const (
	OutcomeSuccess                    OutcomeClass = "success"
	OutcomeRetryableKnownNotCommitted OutcomeClass = "retryable_failure_known_not_committed"
	OutcomePermanentFailure           OutcomeClass = "permanent_failure"
	OutcomeUnknown                    OutcomeClass = "unknown_outcome"
	OutcomeStaleFence                 OutcomeClass = "stale_fence"
)

type Request

type Request struct {
	Metadata     Context        `json:"metadata"`
	Verb         string         `json:"verb"`
	Arguments    map[string]any `json:"arguments"`
	ArgumentHash string         `json:"argument_hash"`
	ContractHash string         `json:"contract_hash"`
}

Request is the immutable call delivered to an invocation-aware executor.

type ResolverDescriptorProvider

type ResolverDescriptorProvider interface {
	InvocationResolverDescriptor() any
}

ResolverDescriptorProvider returns immutable, JSON-serializable resolver input covered by a generation digest.

type Saga

type Saga struct {
	SagaID         string    `json:"saga_id"`
	EffectID       string    `json:"effect_id"`
	Attempt        uint64    `json:"attempt"`
	Direction      Direction `json:"direction"`
	IdempotencyKey string    `json:"idempotency_key"`
}

Saga identifies one durable effect occurrence and dispatch attempt.

Jump to

Keyboard shortcuts

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