Documentation
¶
Index ¶
- Constants
- func NextPageEndpoint(headers map[string]string) string
- func Read(ctx context.Context, dir string, args ...string) ([]byte, error)
- func WithProgress(ctx context.Context, reporter progress.Reporter) context.Context
- type CommandResponse
- type GetRequest
- type Observer
- func (o *Observer) Execute(ctx context.Context, dir string, args ...string) CommandResponse
- func (o *Observer) Get(ctx context.Context, request GetRequest) (response Response, err error)
- func (o *Observer) GetPages(ctx context.Context, request GetRequest, maxPages int) ([]Response, error)
- func (o *Observer) Read(ctx context.Context, dir string, args ...string) ([]byte, error)
- type Response
Constants ¶
const DefaultMaxPages = 100
DefaultMaxPages bounds a paginated read. GitHub's own maximum page size is 100, so this is 10 000 items — far past anything WB reads — and exists only so a malformed or looping `link` header cannot make a verb run forever.
Variables ¶
This section is empty.
Functions ¶
func NextPageEndpoint ¶ added in v0.89.0
NextPageEndpoint extracts the rel="next" URL from a GitHub link header. It returns "" when there is no next page, which is the ordinary end of a walk.
Types ¶
type CommandResponse ¶
type GetRequest ¶
type Observer ¶
type Observer struct {
StateDir string
Now func() time.Time
Sleep func(context.Context, time.Duration) error
RandomIntn func(int64) int64
Run func(context.Context, string, ...string) commandResult
MaxAttempts int
BaseBackoff time.Duration
MaxBackoff time.Duration
}
type Response ¶
type Response struct {
Body []byte
StatusCode int
Headers map[string]string
Cached bool
ObservedAt time.Time
CacheKey string
RequestHash string
}
func GetPages ¶ added in v0.89.0
GetPages performs a paginated GET and returns one response per page, in order.
It follows GitHub's own `link: <…>; rel="next"` header rather than asking the CLI to paginate. That matters because `gh api --paginate --slurp` — the obvious way to get one JSON document per page — needs a `gh` newer than the 2.45 installed on this fleet, and a land verb that breaks on the installed client sends operators back to raw `gh pr merge`, which is precisely how the cleanup that should have run at landing stopped running.
Every page goes through the ordinary observer, so each is conditionally requested, cached, and throttle-aware exactly like a single-page read.