Documentation
¶
Overview ¶
Package ghsource keeps the inventory 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 Card(_ context.Context, r api.Row) (card.Card, error)
- func EventsFrom(s github.Snapshot, prevChecks string, now time.Time) []dinv.Event
- func Items(r api.Row) []items.Item
- func Module(cfg config.Config, d sourcereg.Deps) (sourcereg.Module, error)
- func MyTeams(ctx context.Context, st *inventory.Store) ([]string, error)
- func Outcome(rep Report, err error) (summary, skipped string, _ error)
- func StoredBudget(ctx context.Context, st *inventory.Store) ([]dgh.Limit, error)
- func UI() *api.PluginUI
- type Collector
- func (c *Collector) DetailMaxAge() time.Duration
- func (c *Collector) Fast(ctx context.Context) (Report, error)
- func (c *Collector) IngestJob() ingest.Job
- func (c *Collector) Refresh(ctx context.Context, ref github.Ref) (dinv.PR, inventory.Detail, error)
- func (c *Collector) Slow(ctx context.Context) (Report, error)
- func (c *Collector) SlowJob(ctx context.Context) (summary, skipped string, err error)
- func (c *Collector) Track(ctx context.Context, ref github.Ref) (port.TrackRead, error)
- type GitHub
- type Publisher
- func (p *Publisher) Delivers(d draft.Delivery) draft.Delivery
- func (p *Publisher) Publish(ctx context.Context, d draft.Draft) (draft.Evidence, error)
- func (p *Publisher) Validate(ctx context.Context, d draft.Draft) error
- func (p *Publisher) Verify(ctx context.Context, d draft.Draft, startedAt time.Time) (draft.Evidence, bool, error)
- func (p *Publisher) Where(ctx context.Context, d draft.Draft) (string, error)
- type Report
Constants ¶
const NudgeRule = "github-nudge"
NudgeRule is the Origin.Rule of the nudge drafts the plugin proposes.
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 Items ¶
Items derives a pull request's items from its row (GTD spec 9.3): what waits on the viewer when the row needs them or is the viewer's own to merge, staff or answer, and what waits on others in scope. A muted row derives as its unmuted situation.
func Module ¶
Module is the GitHub source: pull requests read by the fast pass and served as prrow's rows.
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 *inventory.Store
GH GitHub
WS *workspace.Set // nil when no workspace manager is configured
// Sink is the view sink whose columns WS reports as workspace statuses.
Sink string
Cfg config.Config
Now func() time.Time
MaxPages int // per query, default 10
Log func(format string, args ...any)
// Units is the daemon's unit registry and Links its link store; the fast pass's registration carries them.
Units func() *unit.Registry
Links port.LinkStore
// 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) IngestJob ¶
IngestJob is the fast pass as the source's ingestion job, on a fresh read of the workspaces' mutable part.
func (*Collector) Refresh ¶
Refresh reads ref in full at the priority ctx carries, stores the read and returns the stored row and detail.
type GitHub ¶
type GitHub interface {
SearchStubs(ctx context.Context, q, after string) (github.StubPage, error)
SearchStubsFirst(ctx context.Context, qs []string, first int) ([]github.StubPage, []error, error)
StubsByRef(ctx context.Context, refs []github.Ref) (map[github.Ref]github.Stub, map[github.Ref]error, error)
InventoryByRef(ctx context.Context, refs []github.Ref) (map[github.Ref]github.Snapshot, map[github.Ref]error, dgh.RateLimit, error)
Threads(ctx context.Context, refs map[github.Ref]int) (map[github.Ref][]pr.Thread, map[github.Ref]error, error)
TeamMembers(ctx context.Context, org, slug string) ([]string, error)
Viewer(ctx context.Context) (string, error)
Allow(p dgh.Priority) bool
Budget() map[dgh.Resource]dgh.Limit
FindByBranch(ctx context.Context, queries []github.BranchQuery) (map[github.BranchQuery][]github.BranchMatch, error)
}
type Publisher ¶
type Publisher struct {
GH restClient
Viewer func(ctx context.Context) (string, error)
Events eventRecorder
// People are the persons the unit's items name, for mentions of other providers.
People func(ctx context.Context, u unit.Unit) ([]items.Person, error)
Now func() time.Time
Log func(format string, args ...any)
}
Publisher posts GitHub drafts as issue comments on their pull request.
func (*Publisher) Delivers ¶ added in v0.2.0
Delivers is how GitHub posts a draft of delivery d: every draft but a reaction, which it refuses, is a comment on the pull request.
func (*Publisher) Publish ¶
Publish posts d as a comment. A nudge then records its nudged event, as the nudge intent does, so the comment reads as a nudge; a refused post records none.
func (*Publisher) Validate ¶
Validate refuses a draft GitHub cannot take as a comment on the draft's own pull request.
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 dgh.Limit // the GraphQL budget once the sweep ended
Skipped string // non-empty when the sweep did not run (budget)
Warnings []string
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ghsourcetest holds the GitHub plugin's synthetic rows: one per situation kind, viewer's or others' pull request, in or out of scope, muted or not, each derived by prrow's real deriver.
|
Package ghsourcetest holds the GitHub plugin's synthetic rows: one per situation kind, viewer's or others' pull request, in or out of scope, muted or not, each derived by prrow's real deriver. |