Documentation
¶
Index ¶
- Constants
- Variables
- func GetRandomStatusCode() int
- func IsInvalidBody(resp *http.Response) (bool, error)
- func NewPrimaryClient(base http.RoundTripper, opts ...github_primary_ratelimit.Option) *http.Client
- func NewRateLimitInjecter(base http.RoundTripper, options *RateLimitInjecterOptions) (http.RoundTripper, error)
- func NewSecondaryClient(base http.RoundTripper, opts ...github_secondary_ratelimit.Option) *http.Client
- func SetupInjecterWithOptions(t *testing.T, options RateLimitInjecterOptions, ...) http.RoundTripper
- func SetupPrimaryInjecter(t *testing.T, every time.Duration, sleep time.Duration, ...) http.RoundTripper
- func SetupSecondaryInjecter(t *testing.T, every time.Duration, sleep time.Duration) http.RoundTripper
- func UpTo1SecDelay() time.Duration
- func WaitForNextSleep(injecter http.RoundTripper)
- type RateLimitInjecter
- type RateLimitInjecterOptions
Constants ¶
View Source
const (
InvalidBodyContent = `{"message": "not as expected"}`
)
View Source
const (
SecondaryRateLimitMessage = `You have exceeded a secondary rate limit. Please wait a few minutes before you try again.`
)
Variables ¶
View Source
var SecondaryRateLimitDocumentationURLs = []string{
`https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits`,
`https://docs.github.com/free-pro-team@latest/rest/overview/resources-in-the-rest-api#secondary-rate-limits`,
`https://docs.github.com/en/free-pro-team@latest/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits`,
`https://docs.github.com/en/some-other-option#abuse-rate-limits`,
}
Functions ¶
func GetRandomStatusCode ¶
func GetRandomStatusCode() int
func NewPrimaryClient ¶
func NewPrimaryClient(base http.RoundTripper, opts ...github_primary_ratelimit.Option) *http.Client
func NewRateLimitInjecter ¶
func NewRateLimitInjecter(base http.RoundTripper, options *RateLimitInjecterOptions) (http.RoundTripper, error)
func NewSecondaryClient ¶
func NewSecondaryClient(base http.RoundTripper, opts ...github_secondary_ratelimit.Option) *http.Client
func SetupInjecterWithOptions ¶
func SetupInjecterWithOptions(t *testing.T, options RateLimitInjecterOptions, roundTrippger http.RoundTripper) http.RoundTripper
func SetupPrimaryInjecter ¶
func SetupPrimaryInjecter(t *testing.T, every time.Duration, sleep time.Duration, category github_primary_ratelimit.ResourceCategory) http.RoundTripper
func SetupSecondaryInjecter ¶
func UpTo1SecDelay ¶
func WaitForNextSleep ¶
func WaitForNextSleep(injecter http.RoundTripper)
Types ¶
type RateLimitInjecter ¶
type RateLimitInjecter struct {
Base http.RoundTripper
AbuseAttempts int
// contains filtered or unexported fields
}
func (*RateLimitInjecter) WaitForNextInjection ¶
func (r *RateLimitInjecter) WaitForNextInjection()
type RateLimitInjecterOptions ¶
type RateLimitInjecterOptions struct {
Every time.Duration
InjectionDuration time.Duration
InvalidBody bool
UseXRateLimit bool
UsePrimaryRateLimit bool
DocumentationURL string
HttpStatusCode int
PrimaryRateLimitCategory github_primary_ratelimit.ResourceCategory
}
RateLimitInjecterOptions provide options for the injection. note: Every is the interval between the start of two rate limit injections. It is first counted from the first request, then counted from the end of the last injection.
func (*RateLimitInjecterOptions) IsNoop ¶
func (r *RateLimitInjecterOptions) IsNoop() bool
func (*RateLimitInjecterOptions) Validate ¶
func (r *RateLimitInjecterOptions) Validate() error
Click to show internal directories.
Click to hide internal directories.