Documentation
¶
Overview ¶
Package collect keeps the plugin's store in step with GitHub: a cheap fast sweep that reads only what changed and a slow sweep that rebuilds the scope and catches what the searches no longer return.
Index ¶
- Constants
- func EventsFrom(s api.Snapshot, prevChecks string, now time.Time) []pr.Event
- func MyTeams(ctx context.Context, st *store.DB) ([]string, error)
- func Outcome(rep Report, err error) (summary, skipped string, _ error)
- func StoredBudget(ctx context.Context, st *store.DB) ([]api.Limit, error)
- func UntrackFinished(ctx context.Context, st *store.DB, now func() time.Time, ...)
- type Collector
- func (c *Collector) DetailMaxAge() time.Duration
- func (c *Collector) Fast(ctx context.Context) (Report, error)
- func (c *Collector) ReadOne(ctx context.Context, ref api.Ref) (Read, error)
- func (c *Collector) Refresh(ctx context.Context, ref api.Ref) error
- func (c *Collector) Relink(ctx context.Context) error
- func (c *Collector) Save(ctx context.Context, r Read) error
- func (c *Collector) Slow(ctx context.Context) (Report, error)
- type Config
- type Follows
- type GitHub
- type Listings
- type Read
- type Report
Constants ¶
const TrackMax = 50
TrackMax bounds what every fast sweep reads by reference for tracking alone: three batches of InventoryByRef.
Variables ¶
This section is empty.
Functions ¶
func EventsFrom ¶
EventsFrom turns a snapshot into GitHub events. prevChecks is the stored checks state, so a check event is produced only when it changes.
func MyTeams ¶
MyTeams are the scope teams the viewer belongs to, as the last slow sweep resolved them; nil before the first one or when the stored scope is unreadable.
func Outcome ¶
Outcome is a sweep as a job's outcome: truncation and warnings become the skipped text, so they surface in health without failing the job.
func StoredBudget ¶
StoredBudget is the GitHub budget the last sweep kept, for the client's Restore; nil when none was kept or it is unreadable.
Types ¶
type Collector ¶
type Collector struct {
Store *store.DB
GH GitHub
// WS lists the host's workspaces; nil when it lists none.
WS Listings
// Cfg is the configuration in force at each call.
Cfg func() Config
Now func() time.Time
MaxPages int // per query, default 10
Log func(format string, args ...any)
// Changed tells the host that host-visible state the snapshots do not
// carry changed, such as the viewer's teams; nil tells nothing.
Changed func(ctx context.Context, topics ...sdk.Topic)
// contains filtered or unexported fields
}
func (*Collector) DetailMaxAge ¶
DetailMaxAge is how old a stored detail may grow before a fast run reads its pull request again: the slow interval.
func (*Collector) Fast ¶
Fast is one fast pass: the two-phase pass of the GitHub source, then the reads no stub can stand for, tracked and workspace-linked pull requests the store lacks, and the workspaces' links.
func (*Collector) ReadOne ¶
ReadOne reads ref in full at the priority ctx carries and stores nothing: ErrNotFound when GitHub has no such pull request or will not show it, ErrUnavailable when the read failed.
func (*Collector) Refresh ¶
Refresh reads ref in full at the priority ctx carries and stores the read.
type Config ¶
type Config struct {
Scope scope.Config
ReviewPrefix string
// RateLimitFraction is the share of the rate limit the sweeps may spend.
RateLimitFraction float64
// Slow is the slow sweep's period, which bounds a detail's age.
Slow time.Duration
// NeedsMe are the board columns a workspace waiting on the user sits in.
NeedsMe []string
}
Config is what the collector reads of the configuration in force.
type Follows ¶
type Follows struct {
Store *store.DB
// Read reads a pull request about to be tracked; nil tracks it unread.
Read func(ctx context.Context, ref api.Ref) (Read, error)
// Save stores a read.
Save func(ctx context.Context, r Read) error
Now func() time.Time
// Name is what the refusals call the loop.
Name string
// contains filtered or unexported fields
}
Follows track and untrack the pull requests the user follows by hand, in two phases: a read, which stores nothing, and a follow, which admits the read and stores it.
func (*Follows) Follow ¶
Follow tracks ref once its slot and its state allow it, storing the read ReadTrack kept of it first; a refused track leaves no row.
type GitHub ¶
type GitHub interface {
SearchStubs(ctx context.Context, q, after string) (api.StubPage, error)
SearchStubsFirst(ctx context.Context, qs []string, first int) ([]api.StubPage, []error, error)
StubsByRef(ctx context.Context, refs []api.Ref) (map[api.Ref]api.Stub, map[api.Ref]error, error)
InventoryByRef(ctx context.Context, refs []api.Ref) (map[api.Ref]api.Snapshot, map[api.Ref]error, api.RateLimit, error)
Threads(ctx context.Context, refs map[api.Ref]int) (map[api.Ref][]pr.Thread, map[api.Ref]error, error)
TeamMembers(ctx context.Context, org, slug string) ([]string, error)
Viewer(ctx context.Context) (string, error)
Allow(p api.Priority) bool
Budget() map[api.Resource]api.Limit
FindByBranch(ctx context.Context, queries []api.BranchQuery) (map[api.BranchQuery][]api.BranchMatch, error)
}
type Report ¶
type Report struct {
Queries int
Stubs int
Fetched int // full snapshots read
Events int
Failed int // searches and reads that errored
Truncated []string
RateLimit api.Limit // the GraphQL budget once the sweep ended
Skipped string // non-empty when the sweep did not run (budget)
Warnings []string
}