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
- Variables
- type ActiveLeaseCharge
- type AdmissionCharges
- type AdmissionGrant
- type AdmissionKind
- type AdmissionRequest
- type CandidateToken
- type CapacityBusyError
- func (e *CapacityBusyError) DecisionID() CapacityDecisionID
- func (e *CapacityBusyError) Error() string
- func (e *CapacityBusyError) Resource() CapacityResource
- func (e *CapacityBusyError) RetryAfter() time.Duration
- func (e *CapacityBusyError) Scope() CapacityScope
- func (e *CapacityBusyError) Snapshot() CapacitySnapshot
- type CapacityDecisionID
- type CapacityLimits
- type CapacityResource
- type CapacityScope
- type CapacitySnapshot
- type CapacityUsage
- type Coordinator
- type IdleCandidate
- type LiveCapacityOwnershipError
- type LiveSessionRegistrationsError
- type LiveStoreRegistrationsError
- type ProcessConfig
- type ProcessOwner
- type ReclaimClaim
- type ReclaimClaimID
- type ReclaimOwnershipError
- type ReclaimResult
- type ReclaimTarget
- type RevisionID
- type ScopeSnapshot
- func (s ScopeSnapshot) ActiveReclaims() uint64
- func (s ScopeSnapshot) Identity() string
- func (s ScopeSnapshot) Limits() CapacityLimits
- func (s ScopeSnapshot) PendingAdmissions() uint64
- func (s ScopeSnapshot) QuarantinedStableHandles() uint64
- func (s ScopeSnapshot) ReclaimableStableHandles() uint64
- func (s ScopeSnapshot) Scope() CapacityScope
- func (s ScopeSnapshot) Used() CapacityUsage
- type SessionConfig
- type SessionHandleCharge
- type SessionID
- type SessionRegistration
- type ShareID
- type StableHandleCharge
- type StoreConfig
- type StoreID
- type StoreRegistration
- func (s *StoreRegistration) Admit(ctx context.Context, request AdmissionRequest) (AdmissionGrant, error)
- func (s *StoreRegistration) Close() error
- func (s *StoreRegistration) PublishIdle(candidate IdleCandidate) error
- func (s *StoreRegistration) RegisterSession(config SessionConfig) (*SessionRegistration, error)
- func (s *StoreRegistration) ShareID() ShareID
- func (s *StoreRegistration) Snapshot() CapacitySnapshot
- func (s *StoreRegistration) StoreID() StoreID
- func (s *StoreRegistration) WaitForReclaims() error
- func (s *StoreRegistration) WithdrawIdle(token CandidateToken) bool
- type TraceEvent
- func (e TraceEvent) CandidateToken() CandidateToken
- func (e TraceEvent) ClaimID() ReclaimClaimID
- func (e TraceEvent) DecisionID() CapacityDecisionID
- func (e TraceEvent) Diagnostic() error
- func (v TraceEvent) DiagnosticRecord() diag.Record
- func (e TraceEvent) RevisionID() RevisionID
- func (e TraceEvent) SessionID() SessionID
- func (e TraceEvent) ShareID() ShareID
- func (e TraceEvent) Snapshot() CapacitySnapshot
- func (e TraceEvent) Stage() TraceStage
- func (e TraceEvent) StoreID() StoreID
- type TraceStage
- type Tracer
- type TracerFunc
Constants ¶
const ( DefaultSessionActiveLeases uint64 = 32 DefaultProcessActiveLeases uint64 = 1_024 DefaultSessionStableHandles uint64 = 32 DefaultProcessStableHandles uint64 = 1_024 MinCapacityRetryAfter = time.Millisecond MaxCapacityRetryAfter = 30 * time.Second DefaultCapacityRetryAfter = 250 * time.Millisecond )
Variables ¶
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 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 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 (e *LiveCapacityOwnershipError) Error() string
func (*LiveCapacityOwnershipError) Identity ¶
func (e *LiveCapacityOwnershipError) Identity() string
func (*LiveCapacityOwnershipError) Scope ¶
func (e *LiveCapacityOwnershipError) Scope() CapacityScope
func (*LiveCapacityOwnershipError) Usage ¶
func (e *LiveCapacityOwnershipError) Usage() CapacityUsage
type LiveSessionRegistrationsError ¶
type LiveSessionRegistrationsError struct {
// contains filtered or unexported fields
}
func (*LiveSessionRegistrationsError) Count ¶
func (e *LiveSessionRegistrationsError) Count() int
func (*LiveSessionRegistrationsError) Error ¶
func (e *LiveSessionRegistrationsError) Error() string
func (*LiveSessionRegistrationsError) StoreID ¶
func (e *LiveSessionRegistrationsError) StoreID() StoreID
type LiveStoreRegistrationsError ¶
type LiveStoreRegistrationsError struct {
// contains filtered or unexported fields
}
func (*LiveStoreRegistrationsError) Count ¶
func (e *LiveStoreRegistrationsError) Count() int
func (*LiveStoreRegistrationsError) Error ¶
func (e *LiveStoreRegistrationsError) Error() string
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 (e *ReclaimOwnershipError) ClaimID() ReclaimClaimID
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 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 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
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 StoreRegistration ¶
type StoreRegistration struct {
// contains filtered or unexported fields
}
func (*StoreRegistration) Admit ¶
func (s *StoreRegistration) Admit(ctx context.Context, request AdmissionRequest) (AdmissionGrant, error)
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)