Documentation
¶
Overview ¶
Package background keeps local GitHub metadata fresh without a generation queue, model backend, checkout export or hosted baum service. It hands discovery snapshots to Service.Discovered and nothing else: automatic generation is the daemon's separate scheduler.
Index ¶
- type Discovery
- type Local
- type Problem
- type Registry
- type Retention
- type SavedReview
- type Service
- func (s *Service) Asked(repository string)
- func (s *Service) Errors() map[string]string
- func (s *Service) Handler() http.Handler
- func (s *Service) Limited(host string, until time.Time)
- func (s *Service) Paused(host string) time.Time
- func (s *Service) RefreshInterval() time.Duration
- func (s *Service) RefreshNow(ctx context.Context, clone repos.Clone, numbers []int) ([]discovery.Observation, error)
- func (s *Service) ResetIdentity()
- func (s *Service) Run(ctx context.Context)
- func (s *Service) Sync(ctx context.Context)
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Discovery ¶
type Discovery interface {
Poll(context.Context, github.Repository) (discovery.Snapshot, error)
PollNow(context.Context, github.Repository) (discovery.Snapshot, error)
Probe(context.Context, []github.Repository) (map[string]bool, error)
Observe(context.Context, github.Repository, discovery.Observation) error
}
type Registry ¶
type Registry interface {
Repositories(context.Context) ([]repos.Repository, error)
}
type Retention ¶
Retention reconciles the refs that keep saved review versions' commits in a clone (reviewrefs.Reconcile, within reviewrefs.DefaultLimits). A clone that cannot be opened or reconciled is skipped with a log line.
type SavedReview ¶ added in v0.2.0
type SavedReview struct {
Number int
// State is the saved document's pr_state: open, draft, closed or merged.
State string
// Head is the head the latest version reviewed.
Head string
// Generated is when the latest version was generated, and Started when
// its generation began to read the evidence; zero when unknown.
Generated, Started time.Time
}
SavedReview is a pull request with a saved review in a clone's store, as its latest version records it.
type Service ¶
type Service struct {
Registry Registry
Discovery Discovery
// Refresh must only read GitHub/local evidence and CAS-publish the latest
// saved review. It must never enqueue or invoke generation.
Refresh func(context.Context, repos.Clone, int) (discovery.Observation, error)
// Saved lists the clone's pull requests with a saved review: only those
// are read in the background.
Saved func(context.Context, repos.Clone) ([]SavedReview, error)
// Budget is the credential's GraphQL points budget as discovery last read
// it (discovery.Service.GraphQLBudget); nil leaves it unchecked. Reads
// wait while less than refreshReserve of it is left.
Budget func(context.Context, github.Repository) (discovery.RateLimit, error)
// Discovered receives every snapshot a discovery poll returned without
// error. The daemon passes them to its automatic generation scheduler
// (internal/automatic), which alone decides whether to queue a job; this
// service never enqueues or invokes generation itself.
Discovered func(context.Context, discovery.Snapshot)
// Retain reconciles a clone's retained review refs with its stores and
// reports whether a bound left work for another pass (Retention.Retain);
// nil skips it. Sync calls it per common git directory, see retainDue.
Retain func(context.Context, repos.Clone) (bool, error)
Changed func()
Now func() time.Time
Interval time.Duration
// contains filtered or unexported fields
}
func (*Service) Asked ¶ added in v0.2.0
Asked records a refresh of repository the person asked for: the next pass reads its open saved reviews once more, and again those whose reads failed, stopped or not. Retired reviews of closed pull requests stay retired.
func (*Service) Errors ¶ added in v0.2.0
Errors is the state the app uses to show repository refresh failures. Routine poll times and retry counts do not change this answer.
func (*Service) Limited ¶
Limited records a rate limit another reader of the account's GitHub budget hit, so refreshes wait it out too.
func (*Service) Paused ¶
Paused is when the host's rate limit lets refreshes resume, for another reader of the same account's GitHub budget, such as the PR page's facts (internal/facts), to wait it out too.
func (*Service) RefreshInterval ¶
RefreshInterval is how often the background refresh polls.
func (*Service) RefreshNow ¶
func (s *Service) RefreshNow(ctx context.Context, clone repos.Clone, numbers []int) ([]discovery.Observation, error)
RefreshNow refreshes some pull requests of one clone at once, as Sync refreshes each of them, outside Sync's schedule: a hook event said they changed. It reads every pull request it is asked to, whatever Sync's rules say of it: retired, stopped after failures, or past the hour's request budget, which its reads still count toward. It honors the host's rate pause, which a rate-limited refresh here extends for Sync too, and returns the observations it made. It never enqueues or invokes generation.
func (*Service) ResetIdentity ¶
func (s *Service) ResetIdentity()
ResetIdentity drops credential-dependent backoff without waiting for an old network pass. Its late state/rate writes are fenced by the captured epoch.
func (*Service) Run ¶
Run starts immediately in its caller's goroutine. The host runs it separately from HTTP startup; a slow/offline GitHub never holds the cached inbox hostage. One pass runs at a time: its polls run pollConcurrency at once, its reads one at a time.
func (*Service) Sync ¶
Sync is a single serialized scheduling pass, exposed for deterministic tests. Discovery itself owns conditional requests and credential-wide rate budgets. It polls every due repository first, pollConcurrency at a time, so no repository's pull requests wait behind another's reads, then reads the saved pull requests that are due, those GitHub reported changed first, within refreshBudget.