-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.go
More file actions
32 lines (32 loc) · 1.64 KB
/
Copy pathdoc.go
File metadata and controls
32 lines (32 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Package githubkit is a thin, composable HTTP kernel on top of
// google/go-github/v69: authentication, rate-limit budgeting fed from
// X-RateLimit-* response headers, retry with exponential backoff, typed
// sentinel errors, conditional ETag caching, and concurrent pagination.
//
// The kit wraps rather than replaces go-github: [New] returns a native
// [*github.Client], so every SDK method and type keeps working. All kernel
// behavior lives in the client's http.RoundTripper stack, which means
// consumers get rate limiting, retry, and header-driven budget tracking for
// every call — including calls made with code that has never heard of this
// package.
//
// # Design in one paragraph
//
// Each concern is one small RoundTripper, composed outermost-in as:
// rate-limit gate → header feed → retry → ETag cache → tuned base transport.
// The gate consults a shared [RateLimitCache] that the feed layer keeps
// current from every response; when the cache is empty the gate lazily
// probes GET /rate_limit (which itself feeds the cache through its response
// headers). Retry only re-sends requests that are safe to repeat (429 always,
// since GitHub rejects before processing; 5xx only for idempotent methods).
// [ClassifyError] maps final errors onto package sentinels while preserving
// the underlying [*github.ErrorResponse] for errors.Is and errors.AsType.
//
// # Usage
//
// client, err := githubkit.New(
// githubkit.WithAuthTokenFromEnv("GITHUB_TOKEN", "GH_TOKEN"),
// )
// // client is a *github.Client: use it exactly as before.
// events, _, err := client.Activity.ListEventsPerformedByUser(ctx, "octocat", false, nil)
package githubkit