explore

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 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 explore turns what the user types in Explore into one GitHub search for open pull requests to help on.

Index

Constants

View Source
const DefaultSort = "updated-asc"

DefaultSort puts the pull request that has waited longest first, so whoever asked earlier is not pushed further back.

View Source
const MaxFallbackRepos = 50

MaxFallbackRepos bounds the repositories an author's search is retried in.

View Source
const MaxOwners = 10

MaxOwners bounds the owners free text is scoped to.

View Source
const MaxResults = 30

MaxResults is one page: 100 breaks GitHub's per-query resource limit with the candidate fragment, 50 doubles the cost for results nobody scans.

View Source
const MetaRecent = "explore_recent"

MetaRecent is the store's key of the recent searches.

Variables

This section is empty.

Functions

func AuthorInRepos

func AuthorInRepos(login string, repos []string, sort string, keep []string) []string

AuthorInRepos is login's search again, split by repository: GitHub search hides some accounts' pull requests unless repo: scopes it.

func Order

func Order(sort string) func(a, b github.Candidate) int

Order compares candidates as GitHub's sort does, nil for a sort it cannot tell from a candidate.

Types

type Budget

type Budget func() (ok bool, l github.Limit)

Budget says whether the budget lets a search run; l is the bucket it read.

type Explorer

type Explorer struct {
	GitHub GitHub
	Store  Store
	Budget Budget
	// Loop names the loop, as the searches of the repositories it knows
	// say.
	Loop string
	// Attempt bounds one search and Pause separates its two tries; zero
	// is the default.
	Attempt, Pause time.Duration
	// contains filtered or unexported fields
}

Explorer runs Explore's searches, one at a time, only when the user asks, never below the budget the sweeps keep.

func (*Explorer) Recent

func (x *Explorer) Recent(ctx context.Context) ([]string, error)

Recent are the last searches, the newest first.

func (*Explorer) Search

func (x *Explorer) Search(ctx context.Context, input string) (Result, error)

Search runs one search of input.

type GitHub

type GitHub interface {
	Searcher
	IsUser(ctx context.Context, login string) (bool, error)
}

GitHub is what Explore reads of GitHub: its searches and whether a word is a user's login.

type Lookup

type Lookup struct {
	Repos  []string // owner/name of the repositories the inventory holds
	Owners []string // their owners, the most relevant first
	// IsUser answers whether a word is a GitHub user's login; nil, or an
	// error, reads the word as text.
	IsUser func(ctx context.Context, login string) (bool, error)
}

Lookup is what the inventory and GitHub tell Explore about a bare word.

type Request

type Request struct {
	Ref    *github.Ref
	Query  string
	Read   string // how the input was read, after "as"
	Author string // the login when the search lists one author's pull requests
	Team   string // org/slug when the search lists what one team is asked to review
	Sort   string // the value of the search's sort: qualifier
	// Keep are the updated: qualifiers, which every search of the request
	// carries, the fallback's too.
	Keep []string
}

Request is one pull request when Ref is set, else a search.

func Parse

func Parse(ctx context.Context, input string, l Lookup) (Request, error)

type Result

type Result struct {
	Query      string             `json:"query"`
	Read       string             `json:"read"`
	Total      int                `json:"total"`
	Empty      string             `json:"empty,omitempty"`
	RateLimit  github.RateLimit   `json:"rate_limit"`
	Recent     []string           `json:"recent"`
	Candidates []github.Candidate `json:"candidates"`
}

Result is one search: what it read the query as, the pull requests it found and the budget it spent.

type Retry

type Retry struct {
	Attempt, Pause time.Duration
}

Retry bounds each attempt of a search and pauses before its second try.

func (Retry) AuthorInRepos

func (r Retry) AuthorInRepos(ctx context.Context, s Searcher, queries []string, sort, viewer string) (merged github.CandidatePage, failed []error, err error)

AuthorInRepos runs the searches SearchesPerRequest to a request and merges them in the order sort asks for; failed holds the searches that failed alone, and only all of them failing fails the merge.

func (Retry) Search

func (r Retry) Search(ctx context.Context, s Searcher, q, viewer string) (github.CandidatePage, error)

Search gives a search GitHub could not finish in time one more try after a pause: a gateway error or a timeout often passes.

type Searcher

type Searcher interface {
	SearchCandidates(ctx context.Context, q, viewer string, first int) (github.CandidatePage, error)
	SearchCandidatesEach(ctx context.Context, qs []string, viewer string, first int) ([]github.CandidatePage, []error, error)
	CandidateByRef(ctx context.Context, ref github.Ref, viewer string) (github.CandidatePage, error)
}

Searcher is the GitHub search Explore runs.

type Store

type Store interface {
	Refs(ctx context.Context) ([]github.Ref, error)
	Viewer(ctx context.Context) (string, error)
	Meta(ctx context.Context, key string) (string, error)
	SetMeta(ctx context.Context, key, value string) error
}

Store is what Explore reads and keeps beside GitHub: the pull requests the plugin holds, the viewer, and the recent searches.

Jump to

Keyboard shortcuts

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