incidentstore

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package incidentstore persists the Incidentius event stream in a repository.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExecutionNotFound = errors.New("execution not found")
	ErrExecutionExists   = errors.New("execution already exists")
)
View Source
var ErrExecutionIndexUnavailable = errors.New("execution index unavailable")
View Source
var ErrIncidentNotFound = errors.New("incident not found")
View Source
var ErrInvalidEventCursor = errors.New("invalid event cursor")

ErrInvalidEventCursor identifies all malformed or scope-mismatched cursors. Callers may map it to a non-disclosing request error without parsing storage error text or exposing the cursor's decoded state.

View Source
var ErrInvalidIncidentTransition = errors.New("invalid incident transition")

ErrInvalidIncidentTransition identifies a structurally valid append whose event contradicts the current incident projection. Append distinguishes it from a corrupt stored stream by folding the persisted baseline first, so an HTTP adapter can map only caller-caused state conflicts to INVALID_REQUEST.

Functions

This section is empty.

Types

type ConfiguredStore added in v0.27.0

type ConfiguredStore struct {
	StoreID    string                      `yaml:"storeId" json:"storeId"`
	Kind       incidents.StoreLocationKind `yaml:"kind" json:"kind"`
	Project    *incidents.ProjectRef       `yaml:"project,omitempty" json:"project,omitempty"`
	Repository string                      `yaml:"repository" json:"repository"`
}

ConfiguredStore is one trusted repository route shared by incident and execution evidence. Repository is a checked-out local Git repository root.

func (ConfiguredStore) Location added in v0.27.0

func (ConfiguredStore) Validate added in v0.27.0

func (c ConfiguredStore) Validate() error

type ProjectWatcher added in v0.28.0

type ProjectWatcher interface {
	WatchProject(context.Context, incidents.WatchQuery, incidents.ProjectRef) (incidents.EventStream, error)
}

ProjectWatcher is the repository capability used by a project-scoped HTTP watch. Core WatchQuery intentionally has no project member, so adapters must require this narrower capability instead of allowing foreign incident positions into an opaque cursor and filtering them after the fact.

type RepositoryRoots

type RepositoryRoots struct {
	Application string
	Dedicated   map[string]string
	Projects    map[incidents.ProjectRef]string
}

RepositoryRoots resolves every supported StoreLocation to its checked-out Git repository root. The caller owns cloning, authentication, and sync.

func ResolveRouting added in v0.27.0

func ResolveRouting(projectPaths map[string]string, configured []ConfiguredStore) (RepositoryRoots, map[string]incidents.StoreLocation, error)

ResolveRouting combines project defaults with explicit dedicated, application, or project-repository overrides.

type RepositoryStore

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

RepositoryStore owns one configured incident repository. Project, dedicated, and application repositories use this same implementation and layout; routing decides only which root is supplied.

func NewRepositoryStore

func NewRepositoryStore(location incidents.StoreLocation, root string) (*RepositoryStore, error)

func OpenLocation

func OpenLocation(location incidents.StoreLocation, roots RepositoryRoots) (*RepositoryStore, error)

OpenLocation resolves a store location and opens its repository-backed incident store. It keeps location selection separate from persistence so project, dedicated, and application repositories cannot silently share a fallback directory.

func (*RepositoryStore) Append

func (s *RepositoryStore) Append(ctx context.Context, mutation incidents.Mutation) (result incidents.AppendResult, err error)

func (*RepositoryStore) Close

func (s *RepositoryStore) Close() error

Close releases the root directory handle held by the store.

func (*RepositoryStore) Create added in v0.28.0

func (s *RepositoryStore) Create(ctx context.Context, mutation incidents.CreateMutation) (result incidents.CreateResult, err error)

Create durably reserves and publishes one server-assigned incident ID under the same cross-process lock as the first event. A retry completes a prepared receipt, so an interrupted reservation can neither disappear nor allocate a second incident.

func (*RepositoryStore) Events

func (s *RepositoryStore) Events(ctx context.Context, ref incidents.IncidentRef, afterSeq uint64) (events []incidents.Event, err error)

func (*RepositoryStore) Execution added in v0.27.0

Execution loads an immutable receipt by its store-qualified ID.

func (*RepositoryStore) Executions added in v0.27.0

func (s *RepositoryStore) Executions(ctx context.Context) (records []apicontract.ExecutionRecord, err error)

Executions returns all valid receipts in newest-first order. Filtering and response limits are deliberately applied by the contract-facing service.

func (*RepositoryStore) ExecutionsBounded added in v0.27.0

func (s *RepositoryStore) ExecutionsBounded(ctx context.Context, limit int) (records []apicontract.ExecutionRecord, omitted bool, err error)

ExecutionsBounded returns at most limit receipts while bounding receipt reads. omitted reports that one or more indexed receipts were not read. A negative limit preserves the unbounded internal/listing behavior.

func (*RepositoryStore) List added in v0.28.0

func (s *RepositoryStore) List(ctx context.Context, query incidents.CandidateListQuery) (result []incidents.Incident, err error)

List returns canonical provider candidates. It intentionally applies only status and full project-scope membership; protected backlink filters belong to the current-principal IncidentView layer.

func (*RepositoryStore) Merge

func (s *RepositoryStore) Merge(ctx context.Context, mutation incidents.MergeMutation) (result incidents.MergeResult, err error)

func (*RepositoryStore) Projection

func (s *RepositoryStore) Projection(ctx context.Context, ref incidents.IncidentRef, at *time.Time) (projection incidents.Incident, err error)

func (*RepositoryStore) PutExecution added in v0.27.0

func (s *RepositoryStore) PutExecution(ctx context.Context, record apicontract.ExecutionRecord) error

PutExecution appends one immutable execution receipt to the routed evidence repository. The receipt is never overwritten, including by an idempotent retry, because an execution ID names exactly one immutable observation.

func (*RepositoryStore) Watch added in v0.28.0

func (*RepositoryStore) WatchProject added in v0.28.0

func (*RepositoryStore) WatchProjectSnapshot added in v0.28.0

func (s *RepositoryStore) WatchProjectSnapshot(ctx context.Context, query incidents.WatchQuery, project incidents.ProjectRef) (incidents.EventStream, error)

func (*RepositoryStore) WatchSnapshot added in v0.28.0

type SnapshotWatcher added in v0.28.0

type SnapshotWatcher interface {
	WatchSnapshot(context.Context, incidents.WatchQuery) (incidents.EventStream, error)
	WatchProjectSnapshot(context.Context, incidents.WatchQuery, incidents.ProjectRef) (incidents.EventStream, error)
}

SnapshotWatcher opens deterministic finite streams for the events command. Each stream captures an upper sequence bound under the repository lock and returns io.EOF after that exact snapshot, without a timing-based quiet period. Project snapshots use the same scope-bound cursor as live watches.

Jump to

Keyboard shortcuts

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