pulse

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 4 Imported by: 0

Documentation

Overview

Package pulse contains the in-memory coordination primitives for Corvint Pulse.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig       = errors.New("pulse: invalid actor configuration")
	ErrStopped             = errors.New("pulse: actor stopped")
	ErrInvalidated         = errors.New("pulse: capture invalidated")
	ErrGenerationConflict  = errors.New("pulse: workspace generation conflict")
	ErrGenerationExhausted = errors.New("pulse: workspace generation exhausted")
	ErrSequenceExhausted   = errors.New("pulse: server sequence exhausted")
	ErrIdentityExhausted   = errors.New("pulse: internal snapshot identity exhausted")
	ErrCaptureFailed       = errors.New("pulse: capture failed")
	ErrInvalidManifest     = errors.New("pulse: invalid capture manifest")
	ErrSnapshotTooLarge    = errors.New("pulse: snapshot exceeds retention bound")
	ErrForeignToken        = errors.New("pulse: lease token belongs to another actor session")
	ErrLeaseExpired        = errors.New("pulse: snapshot lease expired")
)

Functions

This section is empty.

Types

type Actor

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

Actor serializes all workspace state through one private event loop.

func NewActor

func NewActor(cfg Config) (*Actor, error)

NewActor starts one memory-only workspace actor. SessionID is injected so tests and callers can bind events deterministically; tokens are additionally bound to the concrete actor instance.

func (*Actor) Acquire

func (a *Actor) Acquire(ctx context.Context) (Lease, error)

Acquire starts or joins the active capture for the current generation. A capture committed before admission is historical and never satisfies it.

func (*Actor) Invalidate

func (a *Actor) Invalidate(ctx context.Context, expectedGeneration uint64) (Update, error)

Invalidate advances the workspace generation iff expectedGeneration is current. The accepted command is the cut after which the older capture can no longer publish.

func (*Actor) Resolve

func (a *Actor) Resolve(ctx context.Context, token Token) (Lease, error)

Resolve returns a retained validated-at snapshot. It does not assert that the snapshot is current relative to the workspace.

func (*Actor) Shutdown

func (a *Actor) Shutdown(ctx context.Context) (Update, error)

Shutdown transitions to STOPPING, rejects waiters, cancels the active capture, and terminates the actor. It is idempotent after the first stop.

func (*Actor) Status

func (a *Actor) Status(ctx context.Context) (Status, error)

Status returns actor state at a unique server sequence.

type ActorError

type ActorError struct {
	Cause               error
	WorkspaceGeneration uint64
	ServerSequence      uint64
}

ActorError binds an actor-produced failure to the generation and unique server sequence at which it was committed.

func (*ActorError) Error

func (e *ActorError) Error() string

func (*ActorError) Unwrap

func (e *ActorError) Unwrap() error

type CaptureError

type CaptureError struct {
	Generation uint64
	Cause      error
}

CaptureError preserves both the stable failure class and the injected cause.

func (*CaptureError) Error

func (e *CaptureError) Error() string

func (*CaptureError) Unwrap

func (e *CaptureError) Unwrap() []error

type CaptureFunc

type CaptureFunc func(ctx context.Context, generation uint64) (Manifest, error)

CaptureFunc obtains a manifest for exactly the supplied workspace generation. It must stop promptly when ctx is cancelled.

type Config

type Config struct {
	SessionID            string
	Capture              CaptureFunc
	MaxRetainedSnapshots int
	MaxRetainedBytes     uint64
}

Config defines one memory-only actor instance.

type Lease

type Lease struct {
	Token               Token
	Manifest            Manifest
	SnapshotState       SnapshotState
	WorkspaceGeneration uint64
	ServerSequence      uint64
}

Lease is proof that Manifest was validated at WorkspaceGeneration. It makes no assertion that the generation is still current when the caller reads it.

type Manifest

type Manifest struct {
	WSI               string
	Digest            string
	ObservationWindow ObservationWindow
	ObservationModel  string
	RetainedBytes     uint64
}

Manifest is an immutable-by-construction capture result: all fields are value types. RetainedBytes accounts for immutable data retained behind its digest.

type ObservationWindow

type ObservationWindow struct {
	StartSequence uint64
	EndSequence   uint64
}

ObservationWindow identifies the ordered observations which bounded a capture under its declared observer model.

type SnapshotState

type SnapshotState uint8

SnapshotState deliberately has no CURRENT or STALE value. A lease proves only that its immutable manifest was validated at its workspace generation.

const SnapshotValidatedAt SnapshotState = 1

func (SnapshotState) String

func (s SnapshotState) String() string

type Status

type Status struct {
	Update
	SessionID         string
	RetainedSnapshots int
	RetainedBytes     uint64
}

Status is a point-in-sequence view of actor state.

type Token

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

Token is an opaque, actor-instance-bound snapshot lease token.

type Update

type Update struct {
	State               WorkspaceState
	WorkspaceGeneration uint64
	ServerSequence      uint64
}

Update reports a serialized state transition.

type WorkspaceState

type WorkspaceState uint8

WorkspaceState is the actor's serialized workspace lifecycle state.

const (
	StateEmpty WorkspaceState = iota
	StateCapturing
	StateCaptured
	StateInvalidated
	StateUnknown
	StateStopping
)

func (WorkspaceState) String

func (s WorkspaceState) String() string

Jump to

Keyboard shortcuts

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