Documentation
¶
Overview ¶
Package merged lists a forge's merged PRs page by page within gather's bound, and waits out the forge's rate limits as GitHub says: its retry-after, else until its primary limit resets, else a minute doubling on each repeat, up to a total wait limit. It keeps every PR it listed, even when the forge stops it, so gather can keep what it has, and says how far back a stopped list reached with Stopped.
Index ¶
Constants ¶
const DefaultLimit = 65 * time.Minute
DefaultLimit is how long List waits in total before it gives up: one full hour of the primary limit plus a few secondary waits.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(f forge.MergedPages, since time.Time, max int, w Wait) (prs []forge.PR, more bool, err error)
List returns the PRs merged at or after since, newest merge first, at most max (max 0 or below means no cap). more is true when max stopped the list before since did. It asks f for pages from the first until no page is left or max is reached. When f answers with a *forge.RateLimit it waits as the limit says and asks for the same page again; a wait that would take its total waiting past w.Limit is not slept, and List returns the PRs so far with an error wrapping that limit. Any other error returns the PRs so far and the error.
func Oldest ¶
Oldest returns the oldest merge time of prs, the date a list reached back to; zero when prs is empty.
func Read ¶
func Read(f forge.Forge, since time.Time, max int, w Wait) (prs []forge.PR, more bool, reason string, err error)
Read lists through f the PRs merged at or after since, at most max (0 or below means no cap): page by page with List when f offers forge.MergedPages, else in one call to forge.Merged. reason is not empty when PRs are unavailable: f is nil, offers neither, or is unavailable or unauthenticated before it listed any PR. Any other error, or one after PRs were listed, is a *Stopped, with prs holding every PR listed and more false.
Types ¶
type Stopped ¶
Stopped is the error of a list the forge stopped before it reached back to Since: the PRs kept, PRs of them, reach back to Reached (zero when none were listed), and Err is why the forge stopped.
type Wait ¶
type Wait struct {
// Limit is the most List waits in total; DefaultLimit when zero.
Limit time.Duration
// Sleep waits for a duration; time.Sleep when nil.
Sleep func(time.Duration)
// Now is the current time; time.Now when nil.
Now func() time.Time
// Progress, when set, gets one line for each wait, naming the limit and
// when List resumes.
Progress io.Writer
}
Wait is how List waits out the forge's rate limits. A zero field means its default.
var Defaults Wait
Defaults stands in for the zero fields of every Wait, before the package's own defaults. It is a seam for the tests of callers that make their own Wait, as init does: they set a short Limit and a Sleep and Now that do not wait. Nothing else sets it.