-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
323 additions
and
113 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.github/workflows/integration-testing.yaml → ...rkflows/rabbitmq-integration-testing.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Integration Testing | ||
name: Integration Testing with RabbitMQ | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package middleware | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/bxcodec/goqueue/errors" | ||
"github.com/bxcodec/goqueue/interfaces" | ||
) | ||
|
||
// PublisherDefaultErrorMapper returns a middleware function that maps publisher errors to specific error types. | ||
// It takes a next PublisherFunc as input and returns a new PublisherFunc that performs error mapping. | ||
// If an error occurs during publishing, it will be mapped to a specific error type based on the error code. | ||
// The mapped error will be returned, or nil if no error occurred. | ||
func PublisherDefaultErrorMapper() interfaces.PublisherMiddlewareFunc { | ||
return func(next interfaces.PublisherFunc) interfaces.PublisherFunc { | ||
return func(ctx context.Context, e interfaces.Message) (err error) { | ||
err = next(ctx, e) | ||
if err != nil { | ||
switch err { | ||
case errors.ErrInvalidMessageFormat: | ||
return errors.ErrInvalidMessageFormat | ||
case errors.ErrEncodingFormatNotSupported: | ||
return errors.ErrEncodingFormatNotSupported | ||
default: | ||
return errors.Error{ | ||
Code: errors.UnKnownError, | ||
Message: err.Error(), | ||
} | ||
} | ||
} | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
// InboundMessageHandlerDefaultErrorMapper returns a middleware function that maps specific errors to predefined error types. | ||
// It takes the next inbound message handler function as input and returns a new inbound message handler function. | ||
// The returned function checks if an error occurred during the execution of the next handler function. | ||
// If an error is found, it maps the error to a predefined error type and returns it. | ||
// If no error is found, it returns nil. | ||
func InboundMessageHandlerDefaultErrorMapper() interfaces.InboundMessageHandlerMiddlewareFunc { | ||
return func(next interfaces.InboundMessageHandlerFunc) interfaces.InboundMessageHandlerFunc { | ||
return func(ctx context.Context, m interfaces.InboundMessage) (err error) { | ||
err = next(ctx, m) | ||
if err != nil { | ||
switch err { | ||
case errors.ErrInvalidMessageFormat: | ||
return errors.ErrInvalidMessageFormat | ||
case errors.ErrEncodingFormatNotSupported: | ||
return errors.ErrEncodingFormatNotSupported | ||
default: | ||
return errors.Error{ | ||
Code: errors.UnKnownError, | ||
Message: err.Error(), | ||
} | ||
} | ||
} | ||
return nil | ||
} | ||
} | ||
} |
Oops, something went wrong.