revisionwait

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 10 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 revisionwait owns receiver-side scheduling for authenticated revision capacity pressure. It deliberately does not know how protocol responses are authenticated; session adapters construct CapacitySignal only after that proof.

Index

Constants

View Source
const (
	DefaultWaitBudget          = 2 * time.Minute
	MaximumWaitBudget          = 10 * time.Minute
	DefaultAdditiveJitterLimit = 250 * time.Millisecond
	MaximumAdditiveJitterLimit = time.Second
	DefaultVisibilityThreshold = 500 * time.Millisecond
	MaximumVisibilityThreshold = 5 * time.Second
	WaitIdentityBytes          = protocolsession.IdentityBytes
)
View Source
const (
	MinimumRetryHint = time.Millisecond
	MaximumRetryHint = 30 * time.Second
	GenerationBytes  = protocolsession.IdentityBytes
)

Variables

View Source
var (
	ErrInvalidConfig       = errors.New("revision wait policy configuration is invalid")
	ErrWaitClosed          = errors.New("revision capacity wait is already closed")
	ErrWaitBudgetExhausted = errors.New("revision capacity wait budget exhausted")
	ErrWaitIdentity        = errors.New("revision capacity wait identity generation failed")
	ErrJitterSource        = errors.New("revision capacity jitter source failed")
	ErrTimerContract       = errors.New("revision capacity timer contract failed")
	ErrGenerationContract  = errors.New("revision capacity generation fence contract failed")
)
View Source
var (
	ErrInvalidCapacitySignal  = errors.New("revision capacity signal is invalid")
	ErrInvalidGenerationToken = errors.New("revision wait generation token is invalid")
	ErrGenerationEnded        = errors.New("revision wait protocol generation ended")
	ErrGenerationChanged      = errors.New("revision wait protocol generation changed")
)

Functions

This section is empty.

Types

type CapacitySignal

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

CapacitySignal is scheduling authority only when returned directly by the authenticated session adapter. MatchCapacitySignal intentionally refuses wrappers so a diagnostic error graph cannot acquire retry authority.

func MatchCapacitySignal

func MatchCapacitySignal(err error) (*CapacitySignal, bool)

func NewCapacitySignal

func NewCapacitySignal(spec CapacitySignalSpec) (*CapacitySignal, error)

func (*CapacitySignal) Error

func (signal *CapacitySignal) Error() string

func (*CapacitySignal) Generation

func (signal *CapacitySignal) Generation() GenerationToken

func (*CapacitySignal) ProtocolOperation

func (signal *CapacitySignal) ProtocolOperation() protocolsession.OperationID

func (*CapacitySignal) ProtocolSession

func (signal *CapacitySignal) ProtocolSession() protocolsession.ProtocolSessionID

func (*CapacitySignal) RetryAfter

func (signal *CapacitySignal) RetryAfter() time.Duration

type CapacitySignalSpec

type CapacitySignalSpec struct {
	RetryAfter        time.Duration
	ProtocolSession   protocolsession.ProtocolSessionID
	ProtocolOperation protocolsession.OperationID
	Generation        GenerationToken
}

type Clock

type Clock interface {
	Now() time.Time
}

type Config

type Config struct {
	WaitBudget          time.Duration
	AdditiveJitterLimit time.Duration
	VisibilityThreshold time.Duration
	Clock               Clock
	Timers              TimerFactory
	Jitter              JitterSource
	WaitIDs             WaitIDGenerator
	GenerationFence     GenerationFence
}

type Coordinator

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

func NewCoordinator

func NewCoordinator(config Config) (*Coordinator, error)

func (*Coordinator) NewOperation

func (coordinator *Coordinator) NewOperation(observer Observer, tracer Tracer) (*Operation, error)

func (*Coordinator) Snapshot

func (coordinator *Coordinator) Snapshot() Snapshot

type GenerationChange

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

func NewGenerationEnd

func NewGenerationEnd(previous GenerationToken, cause error) (GenerationChange, error)

func NewGenerationReplacement

func NewGenerationReplacement(previous, current GenerationToken, cause error) (GenerationChange, error)

func (GenerationChange) Cause

func (change GenerationChange) Cause() error

func (GenerationChange) Current

func (change GenerationChange) Current() GenerationToken

func (GenerationChange) Kind

func (change GenerationChange) Kind() GenerationChangeKind

func (GenerationChange) Previous

func (change GenerationChange) Previous() GenerationToken

type GenerationChangeKind

type GenerationChangeKind uint8
const (
	GenerationReplaced GenerationChangeKind = iota + 1
	GenerationLifetimeEnded
)

type GenerationFence

type GenerationFence interface {
	Current() GenerationToken
	WaitForChange(context.Context, GenerationToken) (GenerationChange, error)
}

type GenerationToken

type GenerationToken [GenerationBytes]byte

GenerationToken identifies one native protocol runtime lifetime. It is kept opaque so a future reconnect supervisor can replace the fixed-runtime fence without teaching transfer scheduling how sessions are assembled.

func GenerationTokenFromBytes

func GenerationTokenFromBytes(raw []byte) (GenerationToken, error)

func (GenerationToken) Bytes

func (token GenerationToken) Bytes() []byte

func (GenerationToken) IsZero

func (token GenerationToken) IsZero() bool

type JitterSource

type JitterSource interface {
	AdditiveJitter(time.Duration) (time.Duration, error)
}

type LifetimeFence

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

LifetimeFence turns a runtime lifecycle into the fixed-generation contract native transfer has today. Ending the runtime wakes every retry waiter, while a later runtime necessarily creates a new token and a new transfer job.

func NewLifetimeFence

func NewLifetimeFence(token GenerationToken, lifecycle context.Context) (*LifetimeFence, error)

func (*LifetimeFence) Current

func (fence *LifetimeFence) Current() GenerationToken

func (*LifetimeFence) WaitForChange

func (fence *LifetimeFence) WaitForChange(
	ctx context.Context,
	expected GenerationToken,
) (GenerationChange, error)

type Observer

type Observer interface {
	ObserveRevisionWait(Snapshot)
}

type ObserverFunc

type ObserverFunc func(Snapshot)

func (ObserverFunc) ObserveRevisionWait

func (function ObserverFunc) ObserveRevisionWait(snapshot Snapshot)

type Operation

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

func (*Operation) Cancel

func (operation *Operation) Cancel(cause error)

func (*Operation) ID

func (operation *Operation) ID() WaitID

func (*Operation) Stop

func (operation *Operation) Stop()

Stop clears progress when retry authority is superseded by another result. It emits no terminal fact because that result owns the subsequent diagnosis.

func (*Operation) Succeed

func (operation *Operation) Succeed()

func (*Operation) Wait

func (operation *Operation) Wait(ctx context.Context, signal *CapacitySignal) (WaitOutcome, error)

type Snapshot

type Snapshot struct {
	ActiveWaiters   uint32
	ActiveSince     time.Time
	VisibleAfter    time.Time
	AccumulatedWait time.Duration
	Attempts        uint64
}

func (Snapshot) ActiveDuration

func (snapshot Snapshot) ActiveDuration(now time.Time) time.Duration

func (Snapshot) Visible

func (snapshot Snapshot) Visible(now time.Time) bool

type Timer

type Timer interface {
	Done() <-chan time.Time
	Stop() bool
}

type TimerFactory

type TimerFactory interface {
	NewTimer(time.Duration) Timer
}

type Trace

type Trace struct {
	Stage             TraceStage
	WaitID            WaitID
	ProtocolSession   protocolsession.ProtocolSessionID
	ProtocolOperation protocolsession.OperationID
	Generation        GenerationToken
	Attempt           uint64
	Hint              time.Duration
	Jitter            time.Duration
	Delay             time.Duration
	AccumulatedWait   time.Duration
	ActiveWaiters     uint32
	Cause             error
}

type TraceFunc

type TraceFunc func(Trace)

func (TraceFunc) TraceRevisionWait

func (function TraceFunc) TraceRevisionWait(event Trace)

type TraceStage

type TraceStage uint8
const (
	TraceRetryScheduled TraceStage = iota + 1
	TraceRetryReady
	TraceRetrySucceeded
	TraceBudgetPaused
	TraceWaitCanceled
	TraceGenerationEnded
)

type Tracer

type Tracer interface {
	TraceRevisionWait(Trace)
}

type WaitID

type WaitID [WaitIdentityBytes]byte

func (WaitID) Bytes

func (id WaitID) Bytes() []byte

func (WaitID) IsZero

func (id WaitID) IsZero() bool

type WaitIDGenerator

type WaitIDGenerator interface {
	NewWaitID() (WaitID, error)
}

type WaitOutcome

type WaitOutcome uint8
const (
	WaitRetry WaitOutcome = iota + 1
	WaitBudgetPaused
	WaitCanceled
	WaitGenerationEnded
)

Jump to

Keyboard shortcuts

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