effect

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 4 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 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) Owner

func (s *EffectScope) Owner() string

Owner returns the scope's owner.

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

Jump to

Keyboard shortcuts

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