Repository navigation
rpc: subscribe on reconnection - #689
Conversation
|
wow! thanks a lot |
| c.Logger.Error("failed to redial", "err", err) | ||
| } else { | ||
| c.Logger.Info("reconnected") | ||
| c.ReconnectCh <- true |
There was a problem hiding this comment.
I'd prefer an optional callback here:
go c.OnReconnect()
this way user won't be forced to read from ReconnectCh (because if he isn't, a client would block now).
There was a problem hiding this comment.
@melekes does this apply though since I believe that ReconnectCh was exported so that we could use it in rpc/client/httpclient.go at https://github.com/tendermint/tendermint/pull/689/files#diff-a969276db2d519208a2bf7aa9447acf6R338

as this file is in rpc/lib/client so we need that visibility to be able to use it there.
There was a problem hiding this comment.
You're true, for me it is the best way to delegate reconnection behavior to WSEvents.
I've just fixed the unit tests.
There was a problem hiding this comment.
@odeke-em yes, it is. you probably did not notice, but OnReconnect is also exported. so in httpclient we should be able to do:
w.ws.OnReconnect = func() {
w.redoSubscriptions()
}
There was a problem hiding this comment.
I rewrote some code here da5bd25. Feel free to leave your comments.
Codecov Report
@@ Coverage Diff @@
## unstable #689 +/- ##
============================================
- Coverage 56.59% 56.33% -0.26%
============================================
Files 80 81 +1
Lines 8386 8408 +22
============================================
- Hits 4746 4737 -9
- Misses 3231 3265 +34
+ Partials 409 406 -3 |
* rpc: subscribe on reconnection * rpc: fix unit tests
…nt#689) * Repro in e2e tests * Change something in the code * Fix race condition in `SwitchToConsensus` * Revert "Repro in e2e tests" This reverts commit 4f441f8ebac8f245d5a641c25ccdfa3b382ca063. * RAII lock (cherry picked from commit 6a96eca) Co-authored-by: Sergio Mena <[email protected]>
When connection is lost with server, client does not re-subscribe so client is not notified anymore.