loader

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package loader rebuilds execution states: snapshot + tail of the log, the flow definition the execution is bound to, and archived executions.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotArchived = errors.New("loader: execution is not archived")

ErrNotArchived is returned when an execution has no archive.

Functions

func SegmentObject

func SegmentObject(execID string, first int) string

SegmentObject names the archive object of the history segment of execID starting at event index first. Execution ids contain no dots, so it cannot collide with an execution's own archive object.

Types

type ArchivedEvent

type ArchivedEvent struct {
	Seq         uint64          `json:"seq"`
	DecisionEnd bool            `json:"decision_end"`
	Event       json.RawMessage `json:"event"`
}

ArchivedEvent is one event in an archive object.

type Loader

type Loader struct {
	In    *infra.Infra
	Log   *eventlog.Log
	Snaps *snapshot.Store
	Flows *registry.Registry
}

Loader rebuilds states.

func New

func New(in *infra.Infra, log *eventlog.Log, snaps *snapshot.Store, flows *registry.Registry) *Loader

New returns a Loader.

func (*Loader) ArchiveObject

func (l *Loader) ArchiveObject(ctx context.Context, name string) ([]event.Event, error)

ArchiveObject reads one object of the archive store as events.

func (*Loader) Archived

func (l *Loader) Archived(ctx context.Context, execID string) ([]event.Event, error)

Archived returns the archived events of execID (the live log it had when it was archived; segments are separate, see History).

func (*Loader) DefOf

func (l *Loader) DefOf(ctx context.Context, first event.Event) (*flow.Flow, error)

DefOf returns the flow definition named by the first event of a log.

func (*Loader) History

func (l *Loader) History(ctx context.Context, execID string) ([]event.Event, error)

History returns every event of execID, oldest first: the archived history segments (continue-as-new) followed by the live log, or by the archive object of an archived execution. ErrNotArchived means it does not exist.

func (*Loader) IsArchived

func (l *Loader) IsArchived(ctx context.Context, execID string) (bool, error)

IsArchived reports whether an archive object exists for execID.

func (*Loader) Load

func (l *Loader) Load(ctx context.Context, execID string, upTo uint64) (*fold.State, *flow.Flow, error)

Load returns the state of execID folded up to stream sequence upTo (0 = everything) and its flow definition. A missing execution yields an empty state (Exists() == false) and a nil definition.

func (*Loader) LoadArchived

func (l *Loader) LoadArchived(ctx context.Context, execID string, upTo uint64) (*fold.State, *flow.Flow, error)

LoadArchived folds an archived execution.

Jump to

Keyboard shortcuts

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