mateodelnorte / servicebus

Simple service bus for sending events between processes using amqp.
MIT License
420 stars 66 forks source link

Pass through channel/connection close events #88

Closed ryanvm closed 7 years ago

ryanvm commented 7 years ago

This PR adds support for passing through the following additional events:

This allows users of servicebus to respond proactively to connectivity disruptions rather than wait until send() or publish() calls start failing.

There are additional events that may be worth passing through (connection:block, connection:unblock, channel:return, channel:drain), but I don't have a use case for them, so have not included them at this time.

ryanvm commented 7 years ago

@mateodelnorte Do you have any objections with this approach? Any chance I can get this PR merged in?

mateodelnorte commented 7 years ago

Hey @ryanvm. I'll take a look now. Thanks for the PR.

mateodelnorte commented 7 years ago

Thanks, again, @ryanvm. Looks like you can do the same behavior without needing a passEvent function and instead just using bind. I'm going to update your code to do that, and also use a dot notation for the child events, like so:

    conn.on('close', self.emit.bind(self, 'connection.close'));
    conn.on('error', self.emit.bind(self, 'connection.error'));
mateodelnorte commented 7 years ago

merged with above changes, and published to servicebus@2.0.8

mateodelnorte commented 7 years ago

Thanks!

ryanvm commented 7 years ago

Awesome. Thanks!