githubobserver

package
v0.102.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
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

func NextPageEndpoint(headers map[string]string) string

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.

func Read

func Read(ctx context.Context, dir string, args ...string) ([]byte, error)

func WithProgress added in v0.96.6

func WithProgress(ctx context.Context, reporter progress.Reporter) context.Context

WithProgress attaches one transport-neutral progress sink to GitHub reads made below ctx. An explicit GetRequest.Progress takes precedence.

Types

type CommandResponse

type CommandResponse struct {
	Stdout   []byte
	Stderr   []byte
	ExitCode int
	Err      error
}

func Execute

func Execute(ctx context.Context, dir string, args ...string) CommandResponse

type GetRequest

type GetRequest struct {
	Dir         string
	Repository  string
	Target      string
	Head        string
	Endpoint    string
	Query       map[string]string
	Accept      string
	FreshWindow time.Duration
	Progress    progress.Reporter
}

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
}

func Default

func Default() *Observer

func (*Observer) Execute

func (o *Observer) Execute(ctx context.Context, dir string, args ...string) CommandResponse

func (*Observer) Get

func (o *Observer) Get(ctx context.Context, request GetRequest) (response Response, err error)

func (*Observer) GetPages added in v0.89.0

func (o *Observer) GetPages(ctx context.Context, request GetRequest, maxPages int) ([]Response, error)

func (*Observer) Read

func (o *Observer) Read(ctx context.Context, dir string, args ...string) ([]byte, error)

type Response

type Response struct {
	Body        []byte
	StatusCode  int
	Headers     map[string]string
	Cached      bool
	ObservedAt  time.Time
	CacheKey    string
	RequestHash string
}

func Get

func Get(ctx context.Context, request GetRequest) (Response, error)

func GetPages added in v0.89.0

func GetPages(ctx context.Context, request GetRequest, maxPages int) ([]Response, error)

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.

Jump to

Keyboard shortcuts

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