Skip to content

Commit

Permalink
added error to MaxRetriesExceeded func
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Rotermund authored and Wr4thon committed May 6, 2021
1 parent 67626e1 commit fff9876
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions middleware/errorcounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const errorCounterKey = "@errorCounter"
// TODO validate
type ErrorCounterConfig struct {
MaxRetries int32
MaxRetriesExceeded func(gorabbitmq.Context) error
MaxRetriesExceeded func(gorabbitmq.Context, error) error
}

// ErrorCounterWithConfig is a middleware that counts errors when they occur.
Expand All @@ -41,7 +41,7 @@ func ErrorCounterWithConfig(config ErrorCounterConfig) gorabbitmq.MiddlewareFunc

if errorCounter, ok := c.Value(ErrorCounter{}).(int32); ok {
if errorCounter >= config.MaxRetries {
retryError := config.MaxRetriesExceeded(c)
retryError := config.MaxRetriesExceeded(c, err)
if retryError != nil {
return errors.Wrapf(retryError, "failed to execute maxRetriesExceeded handler, after %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion middleware/errorcounter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Test_Middleware(t *testing.T) {
middleware.ErrorCounterWithConfig(
middleware.ErrorCounterConfig{
MaxRetries: 5,
MaxRetriesExceeded: func(gorabbitmq.Context) error {
MaxRetriesExceeded: func(gorabbitmq.Context, error) error {
log.Print("Exceeded!")
return nil
},
Expand Down

0 comments on commit fff9876

Please sign in to comment.