-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: reconnect refactor #229
Conversation
Codecov Report
@@ Coverage Diff @@
## main #229 +/- ##
==========================================
+ Coverage 86.38% 87.44% +1.06%
==========================================
Files 30 31 +1
Lines 2350 2478 +128
==========================================
+ Hits 2030 2167 +137
+ Misses 320 311 -9
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
ed777c2
to
ef3f9e0
Compare
21c430d
to
d82d8f0
Compare
d82d8f0
to
524b61e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good, only nits and a few minor things! Thanks for going the extra mile and adding such thorough tests, that is really good to have. The wrapper is a much cleaner solution as the one proposed in #217, thanks a lot for reacting to the feedback!
aabbcd4
to
81ceda6
Compare
Test case is stable now by checking |
c6864d7
to
4d5f4d0
Compare
4d5f4d0
to
63356cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple blockers mostly related to maintaining public APIs. If you want to learn highly recommend this (for some reason hard to find) rust book on maintaining public APIs. The actual implementation looks much cleaner! Thanks!
698f76f
to
c8de969
Compare
28266eb
to
e6b236b
Compare
@nshaaban-cPacket I tried, found that InternalClient is hard to hide from user because of the callback parameter. Compiler told me that trait is not object safe if I move emit function with generic type in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solution three: rename ReconnctingClient to Client (and take it's place), and rename existing client to InternalClient
@nshaaban-cPacket I tried, found that InternalClient is hard to hide from user because of the callback parameter. Compiler told me that trait is not object safe if I move emit function with generic type in.
Could you share the compiler message? Would be interesting to see why.
socketio/src/client/reconnect.rs
Outdated
|
||
fn reconnect(&mut self) -> Result<()> { | ||
let mut reconnect_attempts = 0; | ||
if self.builder.reconnect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you @nshaaban-cPacket, this makes sense. Changing the Clients default reconnection behavior is a breaking change anyways, so it would make sense to release a new breaking version and be transparent about what has changed.
@1c3t3a Compiler does not complain until I create a trait object --> socketio/src/client/reconnect.rs:40:8 For more information about this error, try |
d46678c
to
8369f67
Compare
If this is a breaking change anyways, we could expose BOTH ReconnectingClient and Client in the public interface |
What is your definition of |
@1c3t3a If we expose both versions of client,we do not need this. |
I've been testing this for a while now and it works great. I did notice that reconnects don't happen when losing internet connection, it just simply does nothing and stops emitting events. |
@milandekruijf @1c3t3a @nshaaban-cPacket I found the js version of engine.io client will close connection if ping time out. https://github.com/socketio/engine.io-client/blob/dfee8ded722a8c4f9f773505d0c77b4561569863/lib/socket.ts#L645. Suggest @milandekruijf to open a new issue, because the change will be in engine.io layer |
when this feature gonna be available? pls |
What's left to do here:
(Listen to @1c3t3a over me if he says anything different) |
Sounds good! From my experience it was never bad advice to listen to @nshaaban-cPacket :) I would accept any PR that fixes the existing questions. |
1553876
to
71ad1e9
Compare
71ad1e9
to
56b651d
Compare
@1c3t3a @nshaaban-cPacket PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % comment :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocked on removed doc comments from public interface
pub(crate) struct Iter { | ||
socket: Arc<RwLock<RawClient>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(will let it go because it's an internal component)
suggestion: shouldn't need locking here. Should be able to take a ref of Client, and use a poll method (that handles reconnects) similar to before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RawClient is guarded by RwLock in Client, Can not just ref Client without hold the guard, when guard dropped, the ref is invlaid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @SSebo for the feature! Appreciated :)
@nshaaban-cPacket This PR is based on your POC 👍
@nshaaban-cPacket @1c3t3a PTAL