Documentation ¶
Overview ¶
Package retryable is a legacy package, functionality has been moved to reghttp
Index ¶
- Variables
- type Auth
- type Opts
- func WithAuth(auth Auth) Opts
- func WithCertFiles(files []string) Opts
- func WithCerts(certs [][]byte) Opts
- func WithDelay(delayInit time.Duration, delayMax time.Duration) Opts
- func WithHTTPClient(h *http.Client) Opts
- func WithLimit(l int) Opts
- func WithLog(log *logrus.Logger) Opts
- func WithTransport(t *http.Transport) Opts
- func WithUserAgent(ua string) Opts
- type OptsReq
- func WithBodyBytes(body []byte) OptsReq
- func WithBodyFunc(getbody func() (io.ReadCloser, error)) OptsReq
- func WithChunking() OptsReq
- func WithContentLen(l int64) OptsReq
- func WithDigest(d digest.Digest) OptsReq
- func WithHeader(key string, values []string) OptsReq
- func WithHeaders(headers http.Header) OptsReq
- func WithProgressCB(cb func(int64, error)) OptsReq
- func WithScope(repo string, push bool) OptsReq
- type Response
- type Retryable
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAllRequestsFailed when there are no mirrors left to try ErrAllRequestsFailed = errors.New("all requests failed") // ErrBackoffLimit maximum backoff attempts reached ErrBackoffLimit = errors.New("backoff limit reached") // ErrCanceled if the context was canceled ErrCanceled = errors.New("context was canceled") // ErrDigestMismatch if the expected digest wasn't received ErrDigestMismatch = errors.New("digest mismatch") // ErrNotFound isn't there, search for your value elsewhere ErrNotFound = errors.New("not found") // ErrNotImplemented returned when method has not been implemented yet ErrNotImplemented = errors.New("not implemented") // ErrRetryNeeded indicates a request needs to be retried ErrRetryNeeded = errors.New("retry needed") ErrUnauthorized = errors.New("unauthorized") )
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth interface { AddScope(host, scope string) error HandleResponse(*http.Response) error UpdateRequest(*http.Request) error }
Auth is used to process Www-Authenticate header and update request with Authorization header
type Opts ¶
type Opts func(*retryable)
Opts injects options into NewRetryable
func WithCertFiles ¶
WithCertFiles adds certificates by filename
func WithDelay ¶
WithDelay initial time to wait between retries (increased with exponential backoff)
func WithHTTPClient ¶
WithHTTPClient uses a specific http client with retryable requests
func WithTransport ¶
WithTransport uses a specific http transport with retryable requests
type OptsReq ¶
type OptsReq func(*request)
OptsReq injects options into NewRequest
func WithBodyBytes ¶
WithBodyBytes converts a bytes slice into a body func and content length
func WithBodyFunc ¶
func WithBodyFunc(getbody func() (io.ReadCloser, error)) OptsReq
WithBodyFunc includes body content in a request
func WithChunking ¶
func WithChunking() OptsReq
WithChunking allows content to be divided into multiple smaller chunks
func WithDigest ¶
WithDigest verifies the returned content digest matches. Note that the digest is only calculated upon EOF from the downloaded content, so the reader may receive an error rather than EOF from a digest mismatch. The content itself must still be read.
func WithHeaders ¶
WithHeaders includes a header object
func WithProgressCB ¶
WithProgressCB calls the CB function as data is received
type Response ¶
type Response interface { io.ReadCloser HTTPResponse() *http.Response HTTPResponses() ([]*http.Response, error) }
Response is used to handle the result of a request
type Retryable ¶
type Retryable interface { DoRequest(ctx context.Context, method string, u []url.URL, opts ...OptsReq) (Response, error) BackoffClear() BackoffUntil() time.Time }
Retryable is used to create requests with built in retry capabilities
func NewRetryable ¶
NewRetryable returns a retryable interface