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

EventBus.publish() should return a Promise #156

Closed
sroze opened this issue Nov 19, 2019 · 3 comments
Closed

EventBus.publish() should return a Promise #156

sroze opened this issue Nov 19, 2019 · 3 comments

Comments

@sroze
Copy link

sroze commented Nov 19, 2019

I'm submitting a...

[x] Feature request

Current behavior

At the moment, the publish method of the EventBus does return void. When publishing an event, how can I make sure that all handlers have been executed? Without this, I'm at risk of having lost some messages.

Expected behavior

EventBus should return Promise<void>. void because we should not expect any return value.

Others

Do you have any objection against this? The promise would resolve when all handlers have been called.

@sroze sroze changed the title Eve t EventBus.publish() should return a Promise Nov 19, 2019
@kamilmysliwiec
Copy link
Member

The implementation is based on RxJS streams. publish method is intended to be loosely coupled from subscribers and doesn't track whether every EventHandler failed or not.

@sroze
Copy link
Author

sroze commented Feb 11, 2020

@kamilmysliwiec for systems where consistency is really important, it doesn't make sense not to have the ability to know whether or not the message has been received.

publish method is intended to be loosely coupled from subscribers

It it returns a Promise or a way to acknowledge the message has been successfully dispatched (i.e. actually stored in a message bus or, in the example of a synchronous event listener, actually handled) does not couple anything whatsoever, it just allows delivery guarantees.

@kamilmysliwiec
Copy link
Member

@sroze please, note that this library is just a lightweight implementation based on RxJS. Systems vary by requirements and hence, for more sophisticated scenarios, this library should be forked and tailored to the technical expectations of the project (if needed). CQRS and event-based systems is a huge topic and it's pretty much impossible for us to cover every single use-case and provide all possibly useful functionalities out-of-the-box.

@nestjs nestjs locked as resolved and limited conversation to collaborators Feb 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants