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 ¶
- func Saved(ctx context.Context, clone repos.Clone) ([]int, error)
- type Discovery
- type Local
- type Problem
- type Registry
- type Retention
- type Service
- 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 ¶
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 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 func(context.Context, repos.Clone) ([]int, 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) 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 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.