Documentation
¶
Overview ¶
Package effect implements the effect-scope contract (PLUGIN-003, invariant 7): every runtime effect — a timer, subscription, temp state, blob handle, or outbox listener — has an owner, a scope, a disposer, and observable cleanup evidence. Scopes dispose effects LIFO, continue past a failing disposer, and report a CleanupEvidence on close.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CleanupEvidence ¶
type CleanupEvidence struct {
ScopeID string
Owner string
Effects int
Disposed int
Failed int
Duration time.Duration
Reason CloseReason
}
CleanupEvidence is the observable result of a scope close.
type CloseReason ¶
type CloseReason string
CloseReason records why a scope closed.
const ( CloseNormal CloseReason = "normal" CloseTimeout CloseReason = "timeout" CloseShutdown CloseReason = "shutdown" CloseCrashRecovery CloseReason = "crash_recovery" )
type Effect ¶
type Effect struct {
Kind EffectKind
Owner string
Disposer func() error
CreatedAt time.Time
}
Effect is one tracked effect. Disposer must be non-nil; Track rejects a nil disposer because an undisposable effect would be an untracked leak.
type EffectKind ¶
type EffectKind string
EffectKind classifies an effect for telemetry and evidence.
const ( EffectTimer EffectKind = "timer" EffectSubscription EffectKind = "subscription" EffectTempState EffectKind = "temp_state" EffectBlobHandle EffectKind = "blob_handle" EffectOutboxListener EffectKind = "outbox_listener" )
type EffectScope ¶
type EffectScope struct {
// contains filtered or unexported fields
}
EffectScope tracks effects opened on behalf of one owner and disposes them deterministically on Close.
func OpenScope ¶
func OpenScope(ctx contract.OperationContext, owner string) *EffectScope
OpenScope returns a new scope for owner. ScopeID is a ULID so evidence rows sort chronologically and never collide.
func (*EffectScope) Close ¶
func (s *EffectScope) Close(reason CloseReason) CleanupEvidence
Close disposes all tracked effects LIFO, continuing past failures, and returns the CleanupEvidence. It is idempotent: a second Close returns evidence with zero effects.
func (*EffectScope) Failures ¶
func (s *EffectScope) Failures() []ErrDisposalFailure
Failures returns the disposer failures observed during the last Close.
func (*EffectScope) ScopeID ¶
func (s *EffectScope) ScopeID() string
ScopeID returns the scope's identity.
func (*EffectScope) Track ¶
func (s *EffectScope) Track(e Effect) error
Track records an effect for later disposal. A nil disposer is rejected: every tracked effect must be releasable.
type ErrDisposalFailure ¶
type ErrDisposalFailure struct {
ScopeID string
Kind EffectKind
Cause error
}
ErrDisposalFailure wraps a single disposer error, retaining the scope, kind, and underlying cause so operators can attribute the leak.
func (*ErrDisposalFailure) Error ¶
func (e *ErrDisposalFailure) Error() string
func (*ErrDisposalFailure) Unwrap ¶
func (e *ErrDisposalFailure) Unwrap() error