go-marathon icon indicating copy to clipboard operation
go-marathon copied to clipboard

Closing SSE Subscriptions

Open riot-jayb opened this issue 6 years ago • 0 comments

Hello,

We recently noticed when using the event listener functionality that the RemoveEventListener() does not clean up the stream if using SSE mode.

Based on the current code, it seems that this would not be an issue if you (a) reuse the marathon client or (b) use one global SSE listener for all deploys. Unfortunately we are currently recreating marathon client on every deploy, and also trying to subscribe one listener per deploy.

While we have a few options that we control (namely moving towards a global listener or reusing our marathon client), I would think that adding support to RemoveEventListener() to close the stream would be helpful. Do you agree?

If so, I can work on a PR. From a quick pass, it seems reasonable to add an SSE stream close channel to the marathon client struct and send a message down that channel to the stream listening goroutine when RemoveEventListener() is called in SSE mode.

riot-jayb avatar Oct 30 '18 18:10 riot-jayb