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 ¶
- type Indexer
- func (ix *Indexer) ByFlow(ctx context.Context, flow string) ([]string, error)
- func (ix *Indexer) ByFlowEvents(ctx context.Context, flow string) ([]store.Event, error)
- func (ix *Indexer) ByStatus(ctx context.Context, status string) ([]string, error)
- func (ix *Indexer) ByStatusEvents(ctx context.Context, status string) ([]store.Event, error)
- func (ix *Indexer) Reconcile(ctx context.Context) error
- func (ix *Indexer) Run(ctx context.Context) (jetstream.ConsumeContext, error)
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 ¶
New returns an Indexer backed by the store's JetStream context, index buckets and namespace.
func (*Indexer) ByFlowEvents ¶ added in v0.0.2
ByFlowEvents returns the index entries for all executions belonging to flow.
func (*Indexer) ByStatusEvents ¶ added in v0.0.2
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 ¶
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.