in spark/client/retry.go [266:298]
func (r *retriableSparkConnectClient) AddArtifacts(ctx context.Context, opts ...grpc.CallOption) (proto.SparkConnectService_AddArtifactsClient, error) {
var lastErr error
// Create the retry state for this wrapped call. The retry state captures the information about
// the wait time and how many retries to perform.
state := retryState{}
// As long as the error is retriable, we will retry the operation.
canRetry := true
for canRetry {
// Every loop iteration starts with being non-retriable.
canRetry = false
response, lastErr := r.client.AddArtifacts(ctx, opts...)
if lastErr != nil {
for _, h := range r.retryPolicies {
if h.Handler(lastErr) {
canRetry = true
wait := state.nextAttempt(h)
if wait != nil {
time.Sleep(*wait)
} else {
// If the retries are exceeded, simply return from here.
return nil, sparkerrors.WithType(lastErr, sparkerrors.RetriesExceeded)
}
// Breaks out of the retry handler loop.
break
}
}
} else {
// Exit loop if no error has been received.
return response, nil
}
}
return nil, sparkerrors.WithType(lastErr, sparkerrors.RetriesExceeded)
}