roundtripper

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GithubAuthToken         = "GITHUB_AUTH_TOKEN" // #nosec G101
	GithubAppKeyPath        = "GITHUB_APP_KEY_PATH"
	GithubAppID             = "GITHUB_APP_ID"
	GithubAppInstallationID = "GITHUB_APP_INSTALLATION_ID"
	UseDiskCache            = "USE_DISK_CACHE"
	DiskCachePath           = "DISK_CACHE_PATH"
	UseBlobCache            = "USE_BLOB_CACHE"
	BucketURL               = "BLOB_URL"
)

Variables

This section is empty.

Functions

func NewTransport

func NewTransport(ctx context.Context, logger *zap.SugaredLogger) http.RoundTripper

NewTransport returns a configured http.Transport for use with GitHub.

Types

type Cache added in v1.2.0

type Cache struct {
	Bucket *blob.Bucket
}

Cache that use the blob storage like GCS or S3. TODO - Handle returning errors.

func New added in v1.2.0

func New(ctx context.Context, bucketKey string) (*Cache, error)

New opens the bucket for caching.

func (*Cache) Delete added in v1.2.0

func (c *Cache) Delete(key string)

Delete removes key from the cache.The error is not returned to maintain compatabiltiy with the httpcache Cache interface.

func (*Cache) Get added in v1.2.0

func (c *Cache) Get(key string) ([]byte, bool)

Get returns the []byte representation of the response and true if present, false if not.The error is not returned to maintain compatabiltiy with the httpcache Cache interface.

func (*Cache) Set added in v1.2.0

func (c *Cache) Set(key string, resp []byte)

Set saves response resp to the cache with key. The error is not returned to maintain compatabiltiy with the httpcache Cache interface.

type RateLimitRoundTripper

type RateLimitRoundTripper struct {
	Logger         *zap.SugaredLogger
	InnerTransport http.RoundTripper
}

RateLimitRoundTripper is a rate-limit aware http.Transport for Github.

func (*RateLimitRoundTripper) RoundTrip

func (gh *RateLimitRoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

Roundtrip handles caching and ratelimiting of responses from GitHub.

type RoundRobinTokenSource

type RoundRobinTokenSource struct {
	AccessTokens []string
	// contains filtered or unexported fields
}

func (*RoundRobinTokenSource) Token

func (r *RoundRobinTokenSource) Token() (*oauth2.Token, error)

Jump to

Keyboard shortcuts

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