executionregistry

package
v8.0.79 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 6 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 executionregistry tracks Home-dispatched executions for one subscriber lifetime.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRegistryNotAccepting          = errors.New("execution registry is not accepting dispatches")
	ErrRegistryClosed                = errors.New("execution registry is closed")
	ErrInvalidPendingDispatch        = errors.New("invalid pending dispatch")
	ErrInvalidExecutionResource      = errors.New("invalid execution resource")
	ErrExecutionResourceAlreadyBound = errors.New("execution resource is already bound")
)

Functions

This section is empty.

Types

type Freeze

type Freeze struct {
	Revision        int64
	BarrierRevision int64
	Executions      []Observation
}

Freeze is an immutable in-flight execution snapshot.

type Observation

type Observation struct {
	RequestID    string
	CredentialID string
	Model        string
	RequestKind  string
	StartedAt    time.Time
	Accounted    bool
}

Observation is an immutable in-flight execution snapshot entry.

type PendingDispatch

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

PendingDispatch reserves an execution slot until it is installed or ended.

func (*PendingDispatch) End

func (p *PendingDispatch) End()

End releases a dispatch token that was not installed.

type Registry

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

Registry owns all dispatches accepted during one Home subscriber lifetime.

func New

func New() *Registry

New creates an accepting registry.

func (*Registry) BeginDispatch

func (r *Registry) BeginDispatch() (*PendingDispatch, error)

BeginDispatch reserves a dispatch token while the registry accepts traffic.

func (*Registry) Close

func (r *Registry) Close() error

Close permanently rejects new work and closes every currently bound resource.

func (*Registry) Drain

func (r *Registry) Drain(ctx context.Context) error

Drain rejects new work, cancels active resources, and waits for all owners to end.

func (*Registry) FreezeInFlight

func (r *Registry) FreezeInFlight(_ time.Time) Freeze

FreezeInFlight copies all active executions into an immutable snapshot.

func (*Registry) Install

func (r *Registry) Install(pending *PendingDispatch, spec ScopeSpec) (*Scope, error)

Install atomically turns a pending dispatch token into an active execution scope.

func (*Registry) ObserveBarrier

func (r *Registry) ObserveBarrier(revision int64)

ObserveBarrier records the latest Home observation barrier.

func (*Registry) SetReleaseSink

func (r *Registry) SetReleaseSink(rawSink any)

SetReleaseSink replaces the cumulative release sink and replays every known group. Legacy callbacks remain supported but cannot provide acknowledgement tickets.

func (*Registry) WaitPending

func (r *Registry) WaitPending(ctx context.Context) error

WaitPending waits until every dispatch with an unresolved Home response has ended or been installed.

type ReleaseGroup

type ReleaseGroup struct {
	CredentialID string
	Model        string
}

ReleaseGroup identifies the cumulative release sequence for one accounted credential and model.

type ReleaseSink

type ReleaseSink func(ReleaseGroup, int64) *ReleaseTicket

ReleaseSink receives the latest cumulative sequence for a release group and optionally returns an acknowledgement ticket.

type ReleaseTicket

type ReleaseTicket struct {
	Group    ReleaseGroup
	Sequence int64
	// contains filtered or unexported fields
}

ReleaseTicket completes after Home acknowledges a cumulative release sequence.

func NewReleaseTicket

func NewReleaseTicket(group ReleaseGroup, sequence int64, done <-chan struct{}) *ReleaseTicket

NewReleaseTicket creates a ticket backed by done. A nil done channel represents a release sink that does not support acknowledgements.

func (*ReleaseTicket) Wait

func (t *ReleaseTicket) Wait(ctx context.Context) error

Wait blocks until Home acknowledges the release or ctx expires.

type Scope

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

Scope owns the resource for one installed execution.

func (*Scope) Bind

func (s *Scope) Bind(closeFn func() error) error

Bind attaches the execution resource. A scope accepts exactly one resource.

func (*Scope) End

func (s *Scope) End(reason string)

End closes the bound resource and releases this execution scope exactly once.

func (*Scope) EndWithRelease

func (s *Scope) EndWithRelease(_ string) *ReleaseTicket

EndWithRelease closes the scope and returns the release acknowledgement ticket. The release sink is invoked without the registry mutex held.

type ScopeSpec

type ScopeSpec struct {
	RequestID    string
	CredentialID string
	Model        string
	Kind         string
	StartedAt    time.Time
	Accounted    bool
}

ScopeSpec describes a Home-dispatched execution.

type State

type State uint32

State is the lifecycle state of a Registry.

const (
	StateAccepting State = iota
	StateDraining
	StateClosed
)

Jump to

Keyboard shortcuts

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