freshness

package
v0.13.2 Latest Latest
Warning

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

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

Documentation

Overview

Package freshness owns one repository's index, native watcher, startup reconciliation, generation barrier, health, and joined shutdown. Foreground and daemon lifecycles share this owner so process management never forks the graph mutation path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapSyncResult

func MapSyncResult(result indexer.SyncResult) (watch.SyncResult, error)

MapSyncResult maps indexer outcomes into watcher lifecycle semantics.

func ReconcilePaths

func ReconcilePaths(idx *indexer.Indexer, paths []string) (watch.SyncResult, error)

ReconcilePaths uses the canonical indexer path-aware/full-rebuild boundary.

func ReconcileStartup

func ReconcileStartup(idx *indexer.Indexer) (watch.SyncResult, error)

ReconcileStartup performs authoritative incremental startup reconciliation.

func Start

func Start(ctx context.Context, root string, opts Options) (*Owner, StartupResult, error)

Start establishes native coverage first, runs startup reconciliation, then drains the accepted event generation captured after that reconciliation. It returns only at a linearized current point or after joined cleanup.

Types

type Options

type Options struct {
	Watch            watch.Options
	ReconcilePaths   ReconcilePathsFunc
	ReconcileStartup ReconcileStartupFunc
	OnStartupStarted func(time.Time)
	OnStartupDone    func(time.Time, time.Duration, watch.SyncResult, error)
}

Options configures a repository freshness owner.

type Owner

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

Owner holds one open index and its watcher.

func (*Owner) Close

func (o *Owner) Close() error

Close joins watcher work before closing the index. It is idempotent.

func (*Owner) Indexer added in v0.8.0

func (o *Owner) Indexer() *indexer.Indexer

Indexer returns the shared open index owned by this freshness session. Callers may issue concurrent read queries but must not close it.

func (*Owner) Status

func (o *Owner) Status() Status

Status returns live health, deriving currency from watcher generations so an older successful operation cannot hide later queued dirtiness.

func (*Owner) Wait

func (o *Owner) Wait(ctx context.Context) error

Wait blocks until cancellation or a native watcher failure.

type ReconcilePathsFunc

type ReconcilePathsFunc func(*indexer.Indexer, []string) (watch.SyncResult, error)

ReconcilePathsFunc reconciles exact dirty paths; nil requests a full rebuild.

type ReconcileStartupFunc

type ReconcileStartupFunc func(*indexer.Indexer) (watch.SyncResult, error)

ReconcileStartupFunc reconciles authoritative repository state at startup.

type StartupResult

type StartupResult struct {
	Result   watch.SyncResult
	Duration time.Duration
}

StartupResult describes the reconciliation completed before readiness.

type Status

type Status struct {
	ProjectPath           string
	WatchReady            bool
	IndexCurrent          bool
	PendingDirtyPaths     int
	WholeTreeDirty        bool
	AcceptedGeneration    uint64
	CompletedGeneration   uint64
	LastSuccessfulUpdate  time.Time
	LastReconciliation    time.Time
	LastOperationDuration time.Duration
	LastError             string
}

Status is a point-in-time freshness health snapshot.

Jump to

Keyboard shortcuts

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