revisioncapacity

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: 0 modules, 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 revisioncapacity owns process-wide stable-revision and active-lease accounting. It coordinates pressure reclamation without ever holding its lock while invoking a store-owned reclaim target.

Index

Constants

View Source
const (
	DefaultSessionActiveLeases uint64 = 32
	DefaultShareActiveLeases   uint64 = 256
	DefaultProcessActiveLeases uint64 = 1_024

	DefaultSessionStableHandles uint64 = 32
	DefaultShareStableHandles   uint64 = 256
	DefaultProcessStableHandles uint64 = 1_024

	MinCapacityRetryAfter     = time.Millisecond
	MaxCapacityRetryAfter     = 30 * time.Second
	DefaultCapacityRetryAfter = 250 * time.Millisecond
)

Variables

View Source
var (
	ErrCoordinatorClosed     = errors.New("revision capacity coordinator is closed")
	ErrRegistrationClosing   = errors.New("revision capacity registration is closing")
	ErrOwnershipResolved     = errors.New("revision capacity ownership is already resolved")
	ErrOwnershipClaimed      = errors.New("revision capacity ownership has an active reclaim claim")
	ErrOwnershipQuarantined  = errors.New("revision capacity ownership is quarantined")
	ErrInvalidReclaimResult  = errors.New("revision capacity reclaim target violated its ownership contract")
	ErrAdmissionGrantSettled = errors.New("revision capacity admission grant is already settled")
)

Functions

This section is empty.

Types

type ActiveLeaseCharge

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

func (ActiveLeaseCharge) Release

func (c ActiveLeaseCharge) Release() error

func (ActiveLeaseCharge) Valid

func (c ActiveLeaseCharge) Valid() bool

type AdmissionCharges

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

func (AdmissionCharges) ActiveLease

func (c AdmissionCharges) ActiveLease() (ActiveLeaseCharge, bool)

func (AdmissionCharges) Release

func (c AdmissionCharges) Release() error

func (AdmissionCharges) SessionHandle

func (c AdmissionCharges) SessionHandle() (SessionHandleCharge, bool)

func (AdmissionCharges) StableHandle

func (c AdmissionCharges) StableHandle() (StableHandleCharge, bool)

type AdmissionGrant

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

func (AdmissionGrant) Abort

func (g AdmissionGrant) Abort() error

func (AdmissionGrant) Commit

func (g AdmissionGrant) Commit() (AdmissionCharges, error)

func (AdmissionGrant) DecisionID

func (g AdmissionGrant) DecisionID() CapacityDecisionID

func (AdmissionGrant) QuarantineStableHandle

func (g AdmissionGrant) QuarantineStableHandle(cause error) error

QuarantineStableHandle resolves a provisional new-revision admission after a backend acquired a stable source but panicked before terminal Close could be proved. Active/session dimensions are rolled back; the physical unit remains unavailable and observable as quarantined.

func (AdmissionGrant) ReclaimDiagnostic

func (g AdmissionGrant) ReclaimDiagnostic() error

type AdmissionKind

type AdmissionKind uint8
const (
	AdmissionNewRevision AdmissionKind = iota + 1
	AdmissionFirstSessionLease
	AdmissionAdditionalSessionLease
)

type AdmissionRequest

type AdmissionRequest struct {
	Kind       AdmissionKind
	RevisionID RevisionID
	Session    *SessionRegistration
}

type CandidateToken

type CandidateToken string

type CapacityBusyError

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

func (*CapacityBusyError) DecisionID

func (e *CapacityBusyError) DecisionID() CapacityDecisionID

func (*CapacityBusyError) Error

func (e *CapacityBusyError) Error() string

func (*CapacityBusyError) Resource

func (e *CapacityBusyError) Resource() CapacityResource

func (*CapacityBusyError) RetryAfter

func (e *CapacityBusyError) RetryAfter() time.Duration

func (*CapacityBusyError) Scope

func (e *CapacityBusyError) Scope() CapacityScope

func (*CapacityBusyError) Snapshot

func (e *CapacityBusyError) Snapshot() CapacitySnapshot

type CapacityDecisionID

type CapacityDecisionID string

type CapacityLimits

type CapacityLimits CapacityUsage

func DefaultProcessLimits

func DefaultProcessLimits() CapacityLimits

func DefaultSessionLimits

func DefaultSessionLimits() CapacityLimits

func DefaultShareLimits

func DefaultShareLimits() CapacityLimits

type CapacityResource

type CapacityResource uint8
const (
	CapacityResourceStableHandle CapacityResource = iota + 1
	CapacityResourceActiveLease
)

func (CapacityResource) String

func (r CapacityResource) String() string

type CapacityScope

type CapacityScope uint8
const (
	CapacityScopeProcess CapacityScope = iota + 1
	CapacityScopeShare
	CapacityScopeSession
)

func (CapacityScope) String

func (s CapacityScope) String() string

type CapacitySnapshot

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

func (CapacitySnapshot) Closed

func (s CapacitySnapshot) Closed() bool

func (CapacitySnapshot) Process

func (s CapacitySnapshot) Process() ScopeSnapshot

func (CapacitySnapshot) Sessions

func (s CapacitySnapshot) Sessions() []ScopeSnapshot

func (CapacitySnapshot) Share

func (s CapacitySnapshot) Share() ScopeSnapshot

type CapacityUsage

type CapacityUsage struct {
	StableHandles uint64
	ActiveLeases  uint64
}

type Coordinator

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

func (*Coordinator) RegisterStore

func (c *Coordinator) RegisterStore(config StoreConfig, target ReclaimTarget) (*StoreRegistration, error)

type IdleCandidate

type IdleCandidate struct {
	Token               CandidateToken
	RevisionID          RevisionID
	RecoveryUntil       time.Time
	LifecycleGeneration uint64
	StableHandle        StableHandleCharge
}

type LiveCapacityOwnershipError

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

func (*LiveCapacityOwnershipError) Error

func (*LiveCapacityOwnershipError) Identity

func (e *LiveCapacityOwnershipError) Identity() string

func (*LiveCapacityOwnershipError) Scope

func (*LiveCapacityOwnershipError) Usage

type LiveSessionRegistrationsError

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

func (*LiveSessionRegistrationsError) Count

func (*LiveSessionRegistrationsError) Error

func (*LiveSessionRegistrationsError) StoreID

type LiveStoreRegistrationsError

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

func (*LiveStoreRegistrationsError) Count

func (e *LiveStoreRegistrationsError) Count() int

func (*LiveStoreRegistrationsError) Error

type ProcessConfig

type ProcessConfig struct {
	Limits     CapacityLimits
	RetryAfter time.Duration
	Tracer     Tracer
}

func DefaultProcessConfig

func DefaultProcessConfig() ProcessConfig

type ProcessOwner

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

func NewProcessOwner

func NewProcessOwner(config ProcessConfig) (*ProcessOwner, error)

func (*ProcessOwner) Close

func (o *ProcessOwner) Close() error

func (*ProcessOwner) Coordinator

func (o *ProcessOwner) Coordinator() *Coordinator

type ReclaimClaim

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

func (ReclaimClaim) CandidateToken

func (c ReclaimClaim) CandidateToken() CandidateToken

func (ReclaimClaim) ClaimID

func (c ReclaimClaim) ClaimID() ReclaimClaimID

func (ReclaimClaim) DecisionID

func (c ReclaimClaim) DecisionID() CapacityDecisionID

func (ReclaimClaim) LifecycleGeneration

func (c ReclaimClaim) LifecycleGeneration() uint64

func (ReclaimClaim) RecoveryUntil

func (c ReclaimClaim) RecoveryUntil() time.Time

func (ReclaimClaim) RevisionID

func (c ReclaimClaim) RevisionID() RevisionID

type ReclaimClaimID

type ReclaimClaimID string

type ReclaimOwnershipError

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

func (*ReclaimOwnershipError) CandidateToken

func (e *ReclaimOwnershipError) CandidateToken() CandidateToken

func (*ReclaimOwnershipError) ClaimID

func (*ReclaimOwnershipError) DecisionID

func (e *ReclaimOwnershipError) DecisionID() CapacityDecisionID

func (*ReclaimOwnershipError) Error

func (e *ReclaimOwnershipError) Error() string

func (*ReclaimOwnershipError) Unwrap

func (e *ReclaimOwnershipError) Unwrap() error

type ReclaimResult

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

func ReclaimCompleted

func ReclaimCompleted(claim ReclaimClaim, diagnostic error) ReclaimResult

ReclaimCompleted asserts that StableFile.Close returned and ownership is terminal. A diagnostic Close error does not weaken that ownership proof.

func ReclaimDeclined

func ReclaimDeclined(claim ReclaimClaim) ReclaimResult

ReclaimDeclined asserts that the target retained ownership because the store generation no longer matched the claim.

func ReclaimOwnershipUncertain

func ReclaimOwnershipUncertain(claim ReclaimClaim, cause error) ReclaimResult

ReclaimOwnershipUncertain reports that the target cannot prove whether stable ownership became terminal. The coordinator quarantines rather than grants it.

func (ReclaimResult) Diagnostic

func (r ReclaimResult) Diagnostic() error

type ReclaimTarget

type ReclaimTarget interface {
	ReclaimIdle(context.Context, ReclaimClaim) ReclaimResult
}

ReclaimTarget retains store lifecycle authority. It must return Declined if the claim became stale before logical detachment. Once detached, it must finish Close and return Completed or OwnershipUncertain even if ctx is cancelled.

type RevisionID

type RevisionID string

type ScopeSnapshot

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

func (ScopeSnapshot) ActiveReclaims

func (s ScopeSnapshot) ActiveReclaims() uint64

func (ScopeSnapshot) Identity

func (s ScopeSnapshot) Identity() string

func (ScopeSnapshot) Limits

func (s ScopeSnapshot) Limits() CapacityLimits

func (ScopeSnapshot) PendingAdmissions

func (s ScopeSnapshot) PendingAdmissions() uint64

func (ScopeSnapshot) QuarantinedStableHandles

func (s ScopeSnapshot) QuarantinedStableHandles() uint64

func (ScopeSnapshot) ReclaimableStableHandles

func (s ScopeSnapshot) ReclaimableStableHandles() uint64

func (ScopeSnapshot) Scope

func (s ScopeSnapshot) Scope() CapacityScope

func (ScopeSnapshot) Used

func (s ScopeSnapshot) Used() CapacityUsage

type SessionConfig

type SessionConfig struct {
	SessionID SessionID
	Limits    CapacityLimits
}

type SessionHandleCharge

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

func (SessionHandleCharge) Release

func (c SessionHandleCharge) Release() error

func (SessionHandleCharge) Valid

func (c SessionHandleCharge) Valid() bool

type SessionID

type SessionID string

type SessionRegistration

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

func (*SessionRegistration) Close

func (s *SessionRegistration) Close() error

func (*SessionRegistration) SessionID

func (s *SessionRegistration) SessionID() SessionID

func (*SessionRegistration) Snapshot

func (s *SessionRegistration) Snapshot() ScopeSnapshot

type ShareID

type ShareID string

type StableHandleCharge

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

func (StableHandleCharge) Quarantine

func (c StableHandleCharge) Quarantine(cause error) error

Quarantine records a stable handle whose terminal ownership cannot be proved. The unit remains unavailable at process/share scope, while the charge token is resolved so registration teardown cannot wait forever on a backend contract failure.

func (StableHandleCharge) Release

func (c StableHandleCharge) Release() error

func (StableHandleCharge) Valid

func (c StableHandleCharge) Valid() bool

type StoreConfig

type StoreConfig struct {
	Tracer  Tracer
	StoreID StoreID
	ShareID ShareID
	Limits  CapacityLimits
}

StoreConfig binds diagnostics to the registration that owns each fact. Admission/reclaim decisions belong to the requester even when they reclaim another store; idle-handle and ownership facts belong to the affected store.

type StoreID

type StoreID string

type StoreRegistration

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

func (*StoreRegistration) Admit

func (*StoreRegistration) Close

func (s *StoreRegistration) Close() error

func (*StoreRegistration) PublishIdle

func (s *StoreRegistration) PublishIdle(candidate IdleCandidate) error

func (*StoreRegistration) RegisterSession

func (s *StoreRegistration) RegisterSession(config SessionConfig) (*SessionRegistration, error)

func (*StoreRegistration) ShareID

func (s *StoreRegistration) ShareID() ShareID

func (*StoreRegistration) Snapshot

func (s *StoreRegistration) Snapshot() CapacitySnapshot

func (*StoreRegistration) StoreID

func (s *StoreRegistration) StoreID() StoreID

func (*StoreRegistration) WaitForReclaims

func (s *StoreRegistration) WaitForReclaims() error

WaitForReclaims joins callbacks after the caller has fenced local lifecycle state and withdrawn its candidates. This lets a store prove that no callback can still own a claimed stable handle before ordinary terminal cleanup.

func (*StoreRegistration) WithdrawIdle

func (s *StoreRegistration) WithdrawIdle(token CandidateToken) bool

type TraceEvent

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

func (TraceEvent) CandidateToken

func (e TraceEvent) CandidateToken() CandidateToken

func (TraceEvent) ClaimID

func (e TraceEvent) ClaimID() ReclaimClaimID

func (TraceEvent) DecisionID

func (e TraceEvent) DecisionID() CapacityDecisionID

func (TraceEvent) Diagnostic

func (e TraceEvent) Diagnostic() error

func (TraceEvent) DiagnosticRecord

func (v TraceEvent) DiagnosticRecord() diag.Record

func (TraceEvent) RevisionID

func (e TraceEvent) RevisionID() RevisionID

func (TraceEvent) SessionID

func (e TraceEvent) SessionID() SessionID

func (TraceEvent) ShareID

func (e TraceEvent) ShareID() ShareID

func (TraceEvent) Snapshot

func (e TraceEvent) Snapshot() CapacitySnapshot

func (TraceEvent) Stage

func (e TraceEvent) Stage() TraceStage

func (TraceEvent) StoreID

func (e TraceEvent) StoreID() StoreID

type TraceStage

type TraceStage uint8
const (
	TraceAdmissionGranted TraceStage = iota + 1
	TraceAdmissionDenied
	TraceAdmissionCancelled
	TraceReclaimClaimed
	TraceReclaimDeclined
	TraceReclaimCompleted
	TraceReclaimQuarantined
	TraceIdlePublished
	TraceIdleWithdrawn
	TraceOwnershipQuarantined
)

func (TraceStage) DiagnosticName

func (value TraceStage) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

type Tracer

type Tracer interface {
	TraceCapacity(TraceEvent)
}

type TracerFunc

type TracerFunc func(TraceEvent)

func (TracerFunc) TraceCapacity

func (f TracerFunc) TraceCapacity(event TraceEvent)

Jump to

Keyboard shortcuts

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