Skip to content

Commit

Permalink
Merge pull request #29 from jxsl13/chore/improve-recoverable-err-dete…
Browse files Browse the repository at this point in the history
…ction

all unknown errors are recoverable
  • Loading branch information
jxsl13 authored Oct 13, 2023
2 parents a540490 + 446bba8 commit b054a69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: rabbitmq & toxiproxy integration tests

on:
push:
branches: [ "main" ]
Expand All @@ -19,7 +21,10 @@ on:
- 'go.mod'
- 'go.sum'

name: rabbitmq & toxiproxy integration tests
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
Expand Down Expand Up @@ -47,7 +52,7 @@ jobs:

- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest

- name: Run govulncheck
run: govulncheck ./...

Expand Down
12 changes: 4 additions & 8 deletions pool/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pool

import (
"errors"
"net"

"github.com/rabbitmq/amqp091-go"
)
Expand Down Expand Up @@ -38,14 +37,10 @@ func recoverable(err error) bool {
panic("checking nil error for recoverability")
}

oe := &net.OpError{}
if errors.As(err, &oe) {
return true
}

// invalid usage of the amqp protocol is not recoverable
ae := &amqp091.Error{}
switch {
case errors.As(err, &ae), errors.As(err, ae):
case errors.As(err, &ae):
switch ae.Code {
case notImplemented:
return false
Expand All @@ -62,5 +57,6 @@ func recoverable(err error) bool {
}
}

return errors.Is(err, amqp091.ErrClosed)
// every other unknown error is recoverable
return true
}

0 comments on commit b054a69

Please sign in to comment.