visibility

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package visibility maintains the eventually-consistent status/flow indexes (spec §9). An Indexer durably consumes the packtrail-events stream and projects each domain event into the packtrail-idx-status and packtrail-idx-flow KV buckets, idempotently and per-revision: an event is applied only if its execution revision is newer than the one already indexed, so duplicate or out-of-order deliveries — and multiple indexer instances on the same durable — are safe.

A periodic Reconcile authoritatively rebuilds the indexes from the source of truth (packtrail-executions), closing any residual drift. The indexes are best-effort: use them for dashboards and operational search, never for correctness decisions (for those, read packtrail-executions directly).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Indexer

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

Indexer projects domain events into the visibility indexes and answers lookups by status and by flow.

func New

func New(st *store.Store) *Indexer

New returns an Indexer backed by the store's JetStream context, index buckets and namespace.

func (*Indexer) ByFlow

func (ix *Indexer) ByFlow(ctx context.Context, flow string) ([]string, error)

ByFlow returns the ids of executions belonging to flow.

func (*Indexer) ByFlowEvents added in v0.0.2

func (ix *Indexer) ByFlowEvents(ctx context.Context, flow string) ([]store.Event, error)

ByFlowEvents returns the index entries for all executions belonging to flow.

func (*Indexer) ByStatus

func (ix *Indexer) ByStatus(ctx context.Context, status string) ([]string, error)

ByStatus returns the ids of executions currently indexed under status.

func (*Indexer) ByStatusEvents added in v0.0.2

func (ix *Indexer) ByStatusEvents(ctx context.Context, status string) ([]store.Event, error)

ByStatusEvents returns the index entries for all executions under status. Each entry is the most recent event stored for that execution, so callers can build summaries (including the error message) without a per-execution round-trip.

func (*Indexer) Reconcile

func (ix *Indexer) Reconcile(ctx context.Context) error

Reconcile rebuilds the indexes from the source of truth, closing any drift the asynchronous projection may have left behind (spec §9). It scans packtrail-executions and authoritatively re-asserts each execution's membership.

Per §13 this full scan is the part that does not scale to high volumes; the suggested mitigation is to scope the scan to still-active executions and/or archive terminal executions out of the hot bucket.

func (*Indexer) Run

Run starts the durable consumer on packtrail-events and projects every event until ctx is cancelled. The returned ConsumeContext must be stopped by the caller. DeliverAll lets a fresh or restarted indexer catch up from the start of the stream; projection is idempotent so replays are harmless.

Jump to

Keyboard shortcuts

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