-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create middleware duplicating messages #156
Create middleware duplicating messages #156
Conversation
func Duplicator(h message.HandlerFunc) message.HandlerFunc { | ||
return func(msg *message.Message) ([]*message.Message, error) { | ||
events, err := h(msg) | ||
_, _ = h(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handling of these errors is an interesting case. If we'd like to make sure that our system is idempotent, we should probably check if the second handler didn't return an error.
Also worth considering if other middlewares won't cause some weird issues.
return nil, firstErr | ||
} | ||
|
||
_, secondErr := h(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about it for a while, and probably we want to append it to producedMessages
, eventually we can add config for this decorator (like in Retry
) or separated decorator (like in PoisonQueue
or PoisonQueueWithFilter
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix c8baf8a
Co-Authored-By: Robert Laszczak <eventched@gmail.com>
…0/watermill into duplicating-middleware
@roblaszczak @m110 Could you merge the PR? I don't have write access to the repository |
@0michalsokolowski0 Merged, thanks for the contribution! |
Resolving #131