gocryptotrader
gocryptotrader copied to clipboard
stream: shift websocket reader and dialer code from wrapper to stream package
PR Description
~~Opened as draft for initial inspection and critique.~~ This attempts to reduce code duplication for websocket wrappers and gets it another step forward for multi-connection handling.
- Define websocket processor handlers per individual connection - This will eventually be bespoke connections only handling specific assets and or constrained subs.
- Define bootstrap function for bespoke connection startup code per individual connection
- Shift connection dialing and session handling away from wrappers
- Shift websocket reader routines generation to stream package
- Remove proxy field websocket connection as its handled 1 proxy per session anyway
- Adds basic (non-tls) mock server and mock proxy for websocket testing
- Remove superfluous running URL fields as connections can differ
- Adds new currency error
ErrCurrencyPairRequired
- Split
SetWebsocketURL
into two functionsSetWebsocketURL
&&SetWebsocketAuthURL
- Split
GetWebsocketURL
into two functionsGetWebsocketURL
&&GetWebsocketAuthURL
- Removes unused websocket field
DefaultURL
- Removes unexported methods
setState
,setEnabled
,setDataMonitorRunning
,dataMonitorRunning
,checkAndSetMonitorRunning
,setTrafficMonitorRunning
,setConnectionMonitorRunning
and use the field methods directly. - Defered reader.Close in
parseBinaryResponse()
so as to make sure ifio.ReadAll
fails it will still close.
Websocket_Connection
- Remove
setConnectedStatus
andIsConnected
methods in favour of field methods.
Fixes # (issue)
Type of change
Please delete options that are not relevant and add an x
in []
as item is complete.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
How has this been tested
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and also consider improving test coverage whilst working on a certain feature or package.
- [ ] go test ./... -race
- [ ] golangci-lint run
- [ ] Test X
Checklist
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally and on Github Actions with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
Codecov Report
Attention: Patch coverage is 61.06557%
with 95 lines
in your changes are missing coverage. Please review.
Project coverage is 37.78%. Comparing base (
d679a76
) to head (5af9fea
). Report is 3 commits behind head on master.
:exclamation: Current head 5af9fea differs from pull request most recent head 8e9bf16. Consider uploading reports for the commit 8e9bf16 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## master #1493 +/- ##
==========================================
+ Coverage 35.89% 37.78% +1.88%
==========================================
Files 411 411
Lines 177595 147708 -29887
==========================================
- Hits 63752 55815 -7937
+ Misses 106058 84092 -21966
- Partials 7785 7801 +16
Files | Coverage Δ | |
---|---|---|
currency/code.go | 89.17% <ø> (+1.12%) |
:arrow_up: |
exchanges/binance/binance_wrapper.go | 41.09% <100.00%> (+2.87%) |
:arrow_up: |
exchanges/binance/type_convert.go | 60.75% <ø> (+7.15%) |
:arrow_up: |
exchanges/binanceus/binanceus_wrapper.go | 43.88% <100.00%> (+3.80%) |
:arrow_up: |
exchanges/bitfinex/bitfinex_wrapper.go | 40.54% <100.00%> (+3.97%) |
:arrow_up: |
exchanges/bithumb/bithumb.go | 41.42% <100.00%> (+2.14%) |
:arrow_up: |
exchanges/bithumb/bithumb_wrapper.go | 40.86% <100.00%> (+3.18%) |
:arrow_up: |
exchanges/bitmex/bitmex_wrapper.go | 47.60% <100.00%> (+2.39%) |
:arrow_up: |
exchanges/bitstamp/bitstamp_wrapper.go | 57.97% <100.00%> (+5.79%) |
:arrow_up: |
exchanges/btcmarkets/btcmarkets_wrapper.go | 33.41% <100.00%> (+2.87%) |
:arrow_up: |
... and 26 more |
Closing in favour of #1580.