Skip to content
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

Merged
merged 7 commits into from
Nov 14, 2019
Merged

Create middleware duplicating messages #156

merged 7 commits into from
Nov 14, 2019

Conversation

0michalsokolowski0
Copy link
Contributor

Resolving #131

func Duplicator(h message.HandlerFunc) message.HandlerFunc {
return func(msg *message.Message) ([]*message.Message, error) {
events, err := h(msg)
_, _ = h(msg)
Copy link
Member

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)
Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix c8baf8a

Michal Sokolowski and others added 3 commits November 13, 2019 19:00
Co-Authored-By: Robert Laszczak <eventched@gmail.com>
@0michalsokolowski0 0michalsokolowski0 marked this pull request as ready for review November 14, 2019 10:01
@0michalsokolowski0
Copy link
Contributor Author

@roblaszczak @m110 Could you merge the PR? I don't have write access to the repository

@m110 m110 merged commit fe332c0 into ThreeDotsLabs:master Nov 14, 2019
@m110
Copy link
Member

m110 commented Nov 14, 2019

@0michalsokolowski0 Merged, thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants