calmh / node-snmp-native

Native Javascript SNMP library for Node.js
MIT License
252 stars 65 forks source link

add cancel support #47

Closed bangert closed 7 years ago

bangert commented 7 years ago

This adds support for canceling active requests in the session.

Open questions:

TODO:

calmh commented 7 years ago

If this is something we should do, should it not just be a part of close() instead?

bangert commented 7 years ago

Thanks for the fast review!

In our use case, we poll in intervals, and we need to guarantee, that we are finished within a certain time (ie. before the next interval starts), which is why we want to cancel outstanding requests and return immediately.

The reason to introduce a new function is to remain backwards compatible with users, who might rely on the current behavior. But i am not 100% certain how the current behavior could be used constructively...

If you don't have cancel, active request will remain active until at most the maximum timeout value in theory. In practice I've found them to be aborted only by the deadline support - which means they would linger on indefinitely. Presumably because we never call the callback, after the socket has been closed.

bangert commented 7 years ago

Thanks