projection

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 15 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 projection maintains the visibility index: a KV projection of every execution's summary plus membership keys by status, flow and declared search attribute, so List/Query never scan the event stream. It is rebuildable from scratch by replaying the events (reset the dispatcher consumers).

Keys:

x.<exec>                 summary JSON
s.<status>.<exec>        status membership
f.<flow>.<exec>          flow membership
a.<attr>.<hash>.<exec>   search attribute membership (hash of the value)

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFilter = errors.New("projection: invalid filter")

ErrInvalidFilter is returned for a filter value that is not a valid token: it would otherwise become a wildcard in the KV key filter.

Functions

func AttrHash

func AttrHash(v string) string

AttrHash maps an attribute value to a key-safe token.

func Delete added in v1.0.1

func Delete(ctx context.Context, in *infra.Infra, execID string) error

Delete removes an execution from the index: its summary and its flow, attribute, status and quarantine memberships. The memberships are read from the summary, so it goes last: a delete that failed half-way finds them again when it is retried. Deleting an unknown execution is a no-op.

func Index

func Index(ctx context.Context, in *infra.Infra, st *fold.State, created, statusChanged bool) error

Index writes the summary of st. created says the execution is new (flow and attribute memberships are written once); statusChanged says the status membership must move.

func IndexFrom

func IndexFrom(ctx context.Context, in *infra.Infra, st *fold.State, created bool, prev fold.Status) error

IndexFrom is Index for a caller that knows the status before the change (the dispatcher folds it): a new execution gets its status key, a change moves the key from prev, and no other status key is touched. On a cluster every key write is a replicated round trip, so this saves four per change.

func IsQuarantined

func IsQuarantined(ctx context.Context, in *infra.Infra, execID string) (bool, error)

IsQuarantined reports whether execID is quarantined.

func MarkArchived

func MarkArchived(ctx context.Context, in *infra.Infra, execID string) error

MarkArchived flags the summary of an execution as archived.

func Quarantine

func Quarantine(ctx context.Context, in *infra.Infra, execID string, seq uint64, reason string) error

Quarantine records that the dispatcher gave up on execID's events from sequence seq: membership key q.<exec> (checked by every dispatcher) and the summary flag.

func Quarantined

func Quarantined(ctx context.Context, in *infra.Infra) ([]string, error)

Quarantined lists the quarantined executions.

func SetTerminal

func SetTerminal(ctx context.Context, in *infra.Infra, execID string, status fold.Status, reason, errMsg string,
	at time.Time,
) error

SetTerminal records the final status of an execution whose state cannot be folded (quarantined), keeping the rest of its summary.

func Unquarantine

func Unquarantine(ctx context.Context, in *infra.Infra, execID string) error

Unquarantine removes the quarantine mark of execID.

Types

type Filter

type Filter struct {
	Status fold.Status
	Flow   string
	// Attr / Value select by search attribute.
	Attr  string
	Value string
	Limit int
}

Filter selects executions. Empty fields match everything.

type QuarantineMark

type QuarantineMark struct {
	Seq    uint64 `json:"seq"`
	Reason string `json:"reason"`
}

QuarantineMark is the value of q.<exec>: the first event the dispatcher could not process.

func Mark

func Mark(ctx context.Context, in *infra.Infra, execID string) (QuarantineMark, bool, error)

Mark returns the quarantine mark of execID (ok=false when not quarantined).

type Summary

type Summary struct {
	ExecID     string            `json:"exec_id"`
	Flow       string            `json:"flow"`
	FlowHash   string            `json:"flow_hash"`
	Status     fold.Status       `json:"status"`
	Created    time.Time         `json:"created"`
	Updated    time.Time         `json:"updated"`
	Attrs      map[string]string `json:"attrs,omitempty"`
	Parent     *event.ParentRef  `json:"parent,omitempty"`
	ForkedFrom string            `json:"forked_from,omitempty"`
	Error      string            `json:"error,omitempty"`
	Reason     string            `json:"reason,omitempty"`
	LastSeq    uint64            `json:"last_seq"`
	Archived   bool              `json:"archived,omitempty"`
	// Quarantined is set when the dispatcher gave up on this execution's
	// events (see Quarantine); QuarantineReason says why.
	Quarantined      bool   `json:"quarantined,omitempty"`
	QuarantineReason string `json:"quarantine_reason,omitempty"`
}

Summary is the indexed view of an execution.

func Get

func Get(ctx context.Context, in *infra.Infra, execID string) (Summary, error)

Get returns the summary of one execution.

func List

func List(ctx context.Context, in *infra.Infra, f Filter) ([]Summary, error)

List returns the summaries matching f, newest first.

func SummaryOf

func SummaryOf(st *fold.State) Summary

SummaryOf builds the summary of a state.

Jump to

Keyboard shortcuts

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