ghsource

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 45 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const NudgeRule = "github-nudge"

NudgeRule is the Origin.Rule of the nudge drafts the plugin proposes.

Variables

This section is empty.

Functions

func Card

func Card(_ context.Context, r api.Row) (card.Card, error)

Card is a pull request's card, read from its row alone.

func EventsFrom

func EventsFrom(s github.Snapshot, prevChecks string, now time.Time) []dinv.Event

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

func Items(r api.Row) []items.Item

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

func Module(cfg config.Config, d sourcereg.Deps) (sourcereg.Module, error)

Module is the GitHub source: pull requests read by the fast pass and served as prrow's rows.

func MyTeams

func MyTeams(ctx context.Context, st *inventory.Store) ([]string, error)

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

func Outcome(rep Report, err error) (summary, skipped string, _ error)

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

func StoredBudget(ctx context.Context, st *inventory.Store) ([]dgh.Limit, error)

StoredBudget is the GitHub budget the last sweep kept, for the client's Restore; nil when none was kept or it is unreadable.

func UI

func UI() *api.PluginUI

UI is the GitHub plugin's declared contribution: a saved view per served view, in their order, and the menu bar's In loop section; the Inbox and Next hold what needs the user.

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

func (c *Collector) DetailMaxAge() time.Duration

DetailMaxAge is how old a stored detail may grow before a fast run reads its pull request again: the slow interval.

func (*Collector) Fast

func (c *Collector) Fast(ctx context.Context) (Report, error)

Fast is one fast pass, run as the ingestion job runs it.

func (*Collector) IngestJob

func (c *Collector) IngestJob() ingest.Job

IngestJob is the fast pass as the source's ingestion job, on a fresh read of the workspaces' mutable part.

func (*Collector) Refresh

func (c *Collector) Refresh(ctx context.Context, ref github.Ref) (dinv.PR, inventory.Detail, error)

Refresh reads ref in full at the priority ctx carries, stores the read and returns the stored row and detail.

func (*Collector) Slow

func (c *Collector) Slow(ctx context.Context) (Report, error)

func (*Collector) SlowJob

func (c *Collector) SlowJob(ctx context.Context) (summary, skipped string, err error)

SlowJob runs Slow as a daemon job.

func (*Collector) Track

func (c *Collector) Track(ctx context.Context, ref github.Ref) (port.TrackRead, error)

Track reads a pull request the user is about to track.

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

func (p *Publisher) Delivers(d draft.Delivery) draft.Delivery

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

func (p *Publisher) Publish(ctx context.Context, d draft.Draft) (draft.Evidence, error)

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

func (p *Publisher) Validate(ctx context.Context, d draft.Draft) error

Validate refuses a draft GitHub cannot take as a comment on the draft's own pull request.

func (*Publisher) Verify

func (p *Publisher) Verify(ctx context.Context, d draft.Draft, startedAt time.Time) (draft.Evidence, bool, error)

Verify looks for the viewer's comment with d's body among those since startedAt.

func (*Publisher) Where

func (p *Publisher) Where(ctx context.Context, d draft.Draft) (string, error)

Where names the pull request d comments on.

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
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL