Documentation
¶
Overview ¶
Package github is a small read-only GitHub API client. It sends GET requests to the REST API and queries to the GraphQL API, and it never sends a mutation. It waits out rate limits and retries server errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadCursor = errors.New("bad cursor")
ErrBadCursor is returned when GitHub does not accept a paging cursor.
var ErrForbidden = errors.New("github refused the query")
ErrForbidden marks a query the token is not allowed to make.
var ErrNotFound = errors.New("not found")
ErrNotFound marks a 404, or a GraphQL NOT_FOUND. A token without access to a private repository also gets this.
var ErrServer = errors.New("github server error")
ErrServer marks a failure on GitHub's side that a smaller request may avoid, such as a timeout on a heavy GraphQL query.
var ErrUnreachable = errors.New("github cannot be reached")
ErrUnreachable marks a request that never got to GitHub: no network, no name for the host, or nothing that listens there. A smaller request does not help with that.
Functions ¶
Types ¶
type Client ¶
type Client struct {
Token string
// BaseURL is the REST root, without a trailing slash.
BaseURL string
// GraphQLURL is the GraphQL endpoint.
GraphQLURL string
HTTP *http.Client
// MaxWait is the longest single rate-limit wait the client accepts before
// it gives up with an error that names the reset time.
MaxWait time.Duration
// Logf receives progress lines, such as rate-limit waits. May be nil.
Logf func(format string, a ...any)
// Waiting is told how long the client is about to wait for a rate limit.
// A display that sets it shows the wait itself, so the wait is then not
// sent to Logf as well. May be nil.
Waiting func(time.Duration)
// UserAgent is sent with every request.
UserAgent string
// Calls counts HTTP requests sent, including retries. Read it when no
// request is in flight.
Calls int
// contains filtered or unexported fields
}
Client talks to one GitHub host.
func (*Client) GraphQL ¶
GraphQL runs a query and decodes the "data" object into out. Mutations are refused: this client is read-only by construction.