Documentation ¶
Index ¶
- func SetRateLimitTransport(client *http.Client, logger log.Logger)
- func SetRetryTransport(client *http.Client)
- type Connection
- type Downloader
- func (d Downloader) Cleanup(ctx context.Context, currentVersion int) error
- func (d Downloader) DownloadOrganization(ctx context.Context, name string, version int) error
- func (d Downloader) DownloadRepository(ctx context.Context, owner string, name string, version int) error
- func (d Downloader) ListRepositories(ctx context.Context, name string, noForks bool) ([]string, error)
- func (d Downloader) RateRemaining(ctx context.Context) (int, error)
- func (d Downloader) SetCurrent(ctx context.Context, version int) error
- type ErrAbuseRateLimit
- type ErrRateLimit
- type ErrUnauthorized
- type Query
- type RateLimitTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetRateLimitTransport ¶
SetRateLimitTransport wraps the passed client.Transport with a RateLimitTransport
func SetRetryTransport ¶
SetRetryTransport wraps the passed client.Transport with a RetryTransport
Types ¶
type Connection ¶
Connection is a unified interface for GraphQL connections
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader fetches GitHub data using the v4 API
func NewDownloader ¶
NewDownloader creates a new Downloader that will store the GitHub metadata in the given DB. The HTTP client is expected to have the proper authentication setup
func NewMemoryDownloader ¶
NewMemoryDownloader creates a new Downloader that stores GitHub data in memory. The HTTP client is expected to have the proper authentication setup
func NewStdoutDownloader ¶
func NewStdoutDownloader(httpClient *http.Client) (*Downloader, error)
NewStdoutDownloader creates a new Downloader that will print the GitHub metadata to stdout. The HTTP client is expected to have the proper authentication setup
func (Downloader) Cleanup ¶
func (d Downloader) Cleanup(ctx context.Context, currentVersion int) error
Cleanup deletes from the DB all records that do not belong to the currentVersion
func (Downloader) DownloadOrganization ¶
DownloadOrganization downloads the metadata for the given organization and its member users
func (Downloader) DownloadRepository ¶
func (d Downloader) DownloadRepository(ctx context.Context, owner string, name string, version int) error
DownloadRepository downloads the metadata for the given repository and all its resources (issues, PRs, comments, reviews)
func (Downloader) ListRepositories ¶
func (Downloader) RateRemaining ¶
func (d Downloader) RateRemaining(ctx context.Context) (int, error)
RateRemaining returns the remaining rate limit for the v4 GitHub API
func (Downloader) SetCurrent ¶
func (d Downloader) SetCurrent(ctx context.Context, version int) error
SetCurrent enables the given version as the current one accessible in the DB
type ErrAbuseRateLimit ¶
type ErrAbuseRateLimit struct {
// contains filtered or unexported fields
}
ErrAbuseRateLimit is returned when a request triggers any GitHub abuse detection mechanism https://developer.github.com/v3/#abuse-rate-limits
func (*ErrAbuseRateLimit) Error ¶
func (e *ErrAbuseRateLimit) Error() string
type ErrRateLimit ¶
type ErrRateLimit struct {
// contains filtered or unexported fields
}
ErrRateLimit is returned when a request failed because of a RateLimit https://developer.github.com/v4/guides/resource-limitations/#rate-limit
func (*ErrRateLimit) Error ¶
func (e *ErrRateLimit) Error() string
type ErrUnauthorized ¶ added in v0.1.1
type ErrUnauthorized struct {
// contains filtered or unexported fields
}
ErrUnauthorized is returned when a response returns 401
func (*ErrUnauthorized) Error ¶ added in v0.1.1
func (e *ErrUnauthorized) Error() string
type Query ¶
type Query interface {
Connection() Connection
}
Query is a GraphQL query that returns Connection
type RateLimitTransport ¶
RateLimitTransport implements GitHub GraphQL API v4 best practices for avoiding rate limits https://developer.github.com/v4/guides/resource-limitations/#rate-limit https://developer.github.com/v3/#abuse-rate-limits RateLimitTransport will process a Request, and if the response could not be fetched because of a RateLimit or an AbuseRateLimit, it will return an ErrorRateLimit and it no longer process any further Requests until the Limit has been expired. RateLimitTransport does not retry; that behaviour must be implemented by another Transport Each client (with its own token) should use its own RateLimitTransport
func NewRateLimitTransport ¶
func NewRateLimitTransport(rt http.RoundTripper, logger log.Logger) *RateLimitTransport
NewRateLimitTransport returns a new NewRateLimitTransport, who will call the passed http.RoundTripper to process the http.Request Each client (with its own token) should use its own RateLimitTransport