emailjs / emailjs-imap-client

Low-level JS IMAP client for all your IMAP needs.
MIT License
552 stars 123 forks source link

Add option to disable idle #234

Open rpetersen27 opened 4 years ago

rpetersen27 commented 4 years ago

I don't know if anyone will ever have a look at this, but I just thought to give it a try.

This adds a new option idle which defaults to true and which can be used to prevent the connection from idling.

nifgraup commented 4 years ago

Thank @Holorium. Here are questions so I understand this better:

Do you have an example use case for this? Would unsetting the onupdate method be an alternative? Does make more sense to set this as constructor option or turn it off and on with a connected client?

rpetersen27 commented 4 years ago

Hi @nifgraup I am looking at this library from the point of view, that some thousand users will have open IMAP connections. To make sure, that there are no notifications missing, I open two IMAP connections. One for IDLE and another for any other requests. To reduce the number of IDLEing processes, I wanted to disable IDLE for the second connection and just send a NOOP instead. It actually does not matter that much, because I am always connected to a dovecot which supports PUSH-notifications and therefore I don't need to IDLE at all. But it would still be nice if the open connections do not IDLE but just NOOP.

So unsetting onupdate does not help in this case, because my goal is to reduce server load. And for me, it just makes sense to enable/disable it in the constructor as I am going to open new connections with different settings if needed.