iriscouch / follow

Very stable, very reliable, NodeJS CouchDB _changes follower
Apache License 2.0
393 stars 82 forks source link

Proposal: inactivity_ms does not perform as expected/documented, let's fix that. #62

Open grimborg opened 9 years ago

grimborg commented 9 years ago

According to the documentation, when providing a value for inactivity_ms, "If no changes happen by the timeout, Follow will signal an error." But it actually calls on_inactivity, which restarts the feed (see https://github.com/iriscouch/follow/blob/master/lib/feed.js#L624-L637).

In some cases it is not desirable to automatically retry the feed. In my case, for example, I have a large number of databases which I want to stop following once they have been inactive for a while.

Furthemore, the documented behaviour (emiting an error) seems somewhat confusing: the fact that there haven't been changes on a database should not be an error.

Instead, I would propose the following:

This would allow users to indicate what they want Follow to do when there is a timeout, without breaking backwards compatibility.

If you are okay with this proposal, I'll implement it and send a PR.

jcrugzz commented 9 years ago

@grimborg thanks for bringing this up. I made this change a while ago when I felt the erroring could be a bit too aggressive since its not a fatal case. The changes you suggested seem reasonable, I would just make it an inactive event rather than a timeout event. There is already a timeout event that has different semantics currently.

grimborg commented 9 years ago

Thanks for the feedback! I'll emit an inactive event as you propose.