Skip to content

Commit

Permalink
refactor logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
hchienjo committed Mar 5, 2024
1 parent c82aacb commit d32fab6
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions avroregistry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,32 +198,25 @@ func (r *Registry) doRequest(req *http.Request, result interface{}) error {
if err == nil {
return nil
}
if err, ok := err.(*apiError); ok {
if apiErr, ok := err.(*apiError); ok {
// We want to retry on 5xx
// errors, because the Confluent Avro registry
// can occasionally return them as a matter of
// course (and there could also be an
// unavailable service that we're reaching
// through a proxy).
switch err.StatusCode {
case http.StatusInternalServerError:
if !attempt.More() {
return &UnavailableError{err}
}
default:
return err
if apiErr.StatusCode/100 == 5 {
return apiErr
} else {
err = &UnavailableError{apiErr}
}
}

if !attempt.More() {
switch resp.StatusCode {
case http.StatusInternalServerError:
return &UnavailableError{err}
default:
return err
}
return err
}
}

if attempt.Stopped() {
return ctx.Err()
}
Expand Down

0 comments on commit d32fab6

Please sign in to comment.