I have an app that uses Nylas to send email from a user’s own email account. Nylas provides a streaming API that streams messages regarding changes in a user’s inbox, allowing you to keep your app’s cache up to date.
I need this syncing to occur whilst the user is not interacting with the application (because I take actions based on replies to emails I send on the behalf of the users) so I’m thinking that once my app is in sync with the user’s inbox then I will use the streaming API to keep everything in sync. I’m not sure the best approach, but it could involve Job Collection (which I’m already using elsewhere).
However, that seems wrong as a streaming job will never technically ‘finish’. Maybe it’s useful to detect if there’s an error and the stream becomes disconnected? Could it be useful for restarting the streams?
Maybe a job worker isn’t the best approach. Perhaps I need a server that, when started, goes through every connected email account, syncs them and then starts the stream?
Any ideas gratefully received!