Documentation
¶
Overview ¶
Package reviewindex joins GitHub discovery with local immutable version stores. Rebuilds are read-only; no documents are copied into a separate index database.
Index ¶
Constants ¶
const MaxAge = 2 * time.Minute
MaxAge bounds how long a snapshot is served without building again, for what neither an invalidation, the watcher's fingerprint nor a computed expiry covers, such as a clone becoming unavailable through a change the fingerprint does not stat, or a GitHub credential edited outside baum.
Variables ¶
This section is empty.
Functions ¶
func Fingerprint ¶
func Fingerprint(rows func(context.Context) ([]repos.Repository, error), identity func() string) func(context.Context) string
Fingerprint digests what a build reads that may change with no invalidation, without running git or touching a store's files beyond stat: the registry rows (rows, which must not probe clones), identity (the GitHub account revision), and for each clone the size and modification time of its store under both roots store.Open chooses between and of its git config, which holds its remotes, and whether its working tree is still there. A missing file is part of the digest, not an error.
Stores are not opened even to read their header: closing any descriptor of a SQLite file drops the locks this process's own connections hold on it.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache serves one built snapshot to every reader until it is invalidated or expires. Concurrent readers share one build, which runs under the cache's own context so a reader that gives up does not fail the others. Failed builds are not kept. Readers must not mutate a snapshot: it is shared.
func NewCache ¶
NewCache caches s's snapshots. Builds stop when ctx ends. A build after an invalidation reads again only the repositories whose discovery cache, clones or stores changed (parts.go).
func (*Cache) Current ¶
Current is Snapshot with the version of the cached snapshot it returns, which moves each time the cache keeps a new one. It is 0 for a snapshot an invalidation kept out of the cache.
func (*Cache) Fresh ¶
Fresh reports the version of the cached snapshot while one is kept and has not expired.
func (*Cache) Invalidate ¶
func (c *Cache) Invalidate()
Invalidate makes the next reader build again. A build already running still answers the readers waiting on it, but its snapshot is not kept.
type Entry ¶
type Entry struct {
PullRequest discovery.PullRequest `json:"pull_request"`
CloneID string `json:"clone_id,omitempty"`
// NeedsClone marks a repository with no available clone: its pull
// requests are listed from discovery, but a review waits for a clone.
NeedsClone bool `json:"needs_clone,omitempty"`
Status string `json:"status"`
FailureReason string `json:"failure_reason,omitempty"`
VersionCount int `json:"version_count"`
Latest *store.Metadata `json:"latest"`
RiskScore json.RawMessage `json:"risk_score"`
// Historical includes saved reviews outside the current discovered inbox.
// Their state is UNKNOWN unless the saved document already says closed/merged.
Historical bool `json:"historical"`
Stale bool `json:"stale"`
StoreError string `json:"store_error,omitempty"`
Review string `json:"review"`
Merge string `json:"merge"`
Unresolved *int `json:"unresolved"`
UnresolvedCapped bool `json:"unresolved_capped"`
ReviewMinutes *int `json:"review_minutes"`
Checks string `json:"checks"`
MetadataFetchedAt string `json:"metadata_fetched_at,omitempty"`
// ObservedAt is when the observation applied to the entry was fetched, and
// is empty without one. The app counts its age; the index does not, so it
// does not change with time alone.
ObservedAt string `json:"observed_at,omitempty"`
}
type Registry ¶
type Registry interface {
Repositories(context.Context) ([]repos.Repository, error)
}
type Revisions ¶ added in v0.2.0
type Revisions interface {
Revision(context.Context, github.Repository) (discovery.Revision, error)
}
Revisions is a Discovery that stamps what Cached reads without reading it (discovery.Revision). A Cache keeps a repository's rows only while its revision holds, so without it every build reads every repository.
type Service ¶
type Service struct {
Registry Registry
Discovery Discovery
// OpenStore may resolve an explicit --store registration in a future host.
// The default uses the same common-dir/XDG selection as the generation pipeline.
OpenStore func(commonDir string) (Reader, error)
// StoreStamp stamps what OpenStore's reader of commonDir reads, without
// opening it; ok is false when it cannot vouch for it. Two equal stamps
// must read the same summaries. The default, for the default OpenStore,
// stats versions.sqlite and its write-ahead log under both store roots.
// With another OpenStore and no StoreStamp, every build reads every store.
StoreStamp func(commonDir string) (stamp string, ok bool)
}