bitvavo / go-bitvavo-api

Go wrapper for Bitvavo API
ISC License
2 stars 2 forks source link

Non blocking subscription channels & unsubscribe functionality #6

Open dpsarrou opened 3 years ago

dpsarrou commented 3 years ago

Related to Issue #5

Problem

The current mechanism of pushing the WebSocket responses to subscription channels is prone to blocking. For example, if one subscribes to the Ticker for multiple markets but does not consume all the ticker events from all channels (eg. at some point you are no longer interested in a specific ticker and you stop reading from its channel) then the whole handleMessage function will block at the point where the specific channel has reached maximum capacity (100) and cannot push any more messages. This will prevent further consumption of WebSocket responses as well.

Solution

This PR addresses the above with the bare minimum effort. I have restrained from doing any further code improvements (including modularization, formatting, or addressing issues in other parts) in hope that this can be a small change that can be reviewed and accepted quickly. The approach is simple:

What this PR does not address

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication