Overhaul Proxy events #20
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug Fix: Runaway Goroutines
The
startMPDIdlerfunction has a bug which causes the idler goroutine to enter an infinite loop if its connection to MPD is broken. The issue is an incorrectly-used scanner; in the case that MPD closes the connection,sc.Scan()returns false but doesn't error. The Idler only exits on error, so it enters an infinite loop of calling sc.Scan() on a closed socket.Fixes
bufio.Readerfor error-handling at the time that the socket read occurs, as well as direct handling ofio.EOF.Sleepcall to throttle the attempts to reconnect.New Event Pub/Sub System
Create a new
Topictype which supports single-topic publish/subscribe between goroutines.Receivers can subscribe and unsubscribe from the topic, and publishers can create events on
the topic with
Publish.Topicis thread-safe.Refactored the
/go/eventsendpoint to utilize a pub/sub topic to receive updates from the server.Each SSE client subscribes to the topic, and the new "idler" goroutine publishes changes on the other end.
Refactor: Single idler, multiple listeners
Currently, each SSE client uses its own connection to the MPD server when using the "idle" command.
This PR refactors the event system using a pub/sub mechanism:
Frontend Changes