// ShouldRetry returns true if the request should be retried.
434287
func (d DefaultRetryer) ShouldRetry(r *request.Request) bool {
	// If one of the other handlers already set the retry state
	// we don't want to override it based on the service's state
	if r.Retryable != nil {
		return *r.Retryable
	}

	if r.HTTPResponse.StatusCode >= 500 && r.HTTPResponse.StatusCode != 501 {
		return true
	}
	return r.IsErrorRetryable() || d.shouldThrottle(r)
}
1040596
func (p *LogPrefix) IsRetry(c context.Context, nonce []byte) bool {
	if len(nonce) != types.OpNonceLength {
		logging.Infof(c, "user provided invalid nonce length (%d)", len(nonce))
		return false
	}
	if len(p.OpNonce) == 0 {
		logging.Infof(c, "prefix %q has no associated nonce", p.Prefix)
		return false
	}
	if clock.Now(c).After(p.Created.Add(RegistrationNonceTimeout)) {
		logging.Infof(c, "prefix %q has expired nonce", p.Prefix)
		return false
	}
	return subtle.ConstantTimeCompare(p.OpNonce, nonce) == 1
}
1238961
func checkRetry(c *etcd.Cluster, numReqs int, last http.Response, err error) error {
	if numReqs > retryCycles*len(c.Machines) {
		return fmt.Errorf("Tried and failed %d cluster connections: %s", retryCycles, err)
	}

	switch last.StatusCode {
	case 0:
		return nil
	case 500:
		time.Sleep(retrySleep)
		return nil
	case 200:
		return nil
	default:
		return fmt.Errorf("Unhandled HTTP Error: %s %d", last.Status, last.StatusCode)
	}
}
625518
func canRetry(ctx context.Context, err error) bool {
	if err == nil {
		return false
	}

	select {
	case <-ctx.Done():
		return false
	default:
	}

	switch vterrors.Code(err) {
	case vtrpcpb.Code_UNAVAILABLE, vtrpcpb.Code_FAILED_PRECONDITION:
		return true
	}
	return false
}
1067005
func (m *Matcher) ShouldIgnore(filename string) bool {
	switch {
	case fs.IsTemporary(filename):
		return true

	case fs.IsInternal(filename):
		return true

	case m.Match(filename).IsIgnored():
		return true
	}

	return false
}
519557
func RetryMaxRetries(max int) RetryFn {
	return func(attempt Attempt) bool {
		// < instead of <= because attempt.Index is 0-based, so if max = 1
		// (1 retry), it will return true when attempt.Index == 0 only.
		return attempt.Index < max
	}
}
1024601
func (sc *StatementContext) ResetForRetry() {
	sc.mu.Lock()
	sc.mu.affectedRows = 0
	sc.mu.foundRows = 0
	sc.mu.records = 0
	sc.mu.updated = 0
	sc.mu.copied = 0
	sc.mu.touched = 0
	sc.mu.message = ""
	sc.mu.errorCount = 0
	sc.mu.warnings = nil
	sc.mu.execDetails = execdetails.ExecDetails{}
	sc.mu.allExecDetails = make([]*execdetails.ExecDetails, 0, 4)
	sc.mu.Unlock()
	sc.TableIDs = sc.TableIDs[:0]
	sc.IndexIDs = sc.IndexIDs[:0]
}
166811
func canRetry(err error) bool {
	if temp, ok := err.(TemporaryError); ok && temp.Temporary() {
		return true
	}
	return err == ErrRecalculate
}
809213
func getRetryAfter(resp *http.Response) string {
	if resp == nil {
		return ""
	}

	return resp.Header.Get("Retry-After")
}
125063
func (md *MDServerRemote) ShouldRetryOnConnect(err error) bool {
	_, inputCanceled := err.(libkb.InputCanceledError)
	return !inputCanceled
}
569096
func isConsulErrNeedingRetry(err error) bool {
	return strings.Contains(err.Error(), httpError) ||
		strings.Contains(err.Error(), eofError) ||
		strings.Contains(err.Error(), connRefused) ||
		strings.Contains(err.Error(), nameResolutionError)
}
536941
func shouldRetry(status int) bool {
	return status == http.StatusAccepted || status == http.StatusTooManyRequests
}
474869
func (bow *Browser) shouldRedirect(req *http.Request, _ []*http.Request) error {
	if bow.attributes[FollowRedirects] {
		req.Header.Set("User-Agent", bow.userAgent)
		return nil
	}
	return errors.NewLocation(
		"Redirects are disabled. Cannot follow '%s'.", req.URL.String())
}
540719
func (txmgr *LockBasedTxMgr) ShouldRecover(lastAvailableBlock uint64) (bool, uint64, error) {
	savepoint, err := txmgr.GetLastSavepoint()
	if err != nil {
		return false, 0, err
	}
	if savepoint == nil {
		return true, 0, nil
	}
	return savepoint.BlockNum != lastAvailableBlock, savepoint.BlockNum + 1, nil
}
841225
func (t *Task) SetRetry(d time.Duration) *Task {
	t.retry = d
	return t
}
239615
func (r *MyRetryer) ShouldRetry(err error) bool {
	if awsErr, ok := err.(awserr.Error); ok {
		switch awsErr.Code() {
		case dynamodb.ErrCodeProvisionedThroughputExceededException, dynamodb.ErrCodeLimitExceededException:
			return true
		default:
			return false
		}
	}
	return false
}
75543
func (c *Config) AutomaticallyRetryHooks() bool {
	if val, ok := c.defined["automatically-retry-hooks"].(bool); !ok {
		return true
	} else {
		return val
	}
}