-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add support for setting socket max num tries and reconnect timeout #172
Conversation
0a05ffb
to
8b1494e
Compare
Codecov ReportPatch coverage is 📢 Thoughts on this report? Let us know!. |
d2ed8ef
to
1e0a34a
Compare
Going back to draft because of failing tests |
1e0a34a
to
4b99755
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.
Overall it looks very good.
I have added a few comments, regarding the const keyword as it is used somewhere, but not everywhere.
@@ -50,7 +50,7 @@ class TCPSocket | |||
private: | |||
std::atomic<int> socket_fd_; | |||
std::atomic<SocketState> state_; | |||
std::chrono::seconds reconnection_time_; | |||
std::chrono::milliseconds reconnection_time_; |
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 know that reconnection_time was not added in this PR, but I suggest that we add the reconnection_time as an input argument to the setup function instead of a member variable. Then max_num_tries and reconnection_time can be modified in the same way and both variables are only used within the setup function.
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.
That sounds reasonable.
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've added it to the setup
method and added a deprecation notice. Due to being implemented as a default parameter value I couldn't properly overload in order to keep the old and current API stable. Hence, I added a manual conflict resolution to choose the value set through the deprecated API with an additional deprecation notice.
@urmahp I found one more flaw when passing reconnection time to the socket. The tests were succeeding but taking too long, since the default timeout is 10 seconds. I added a limit of 1.5 seconds (since the connection should take 2*500ms+overhead). This way we can make sure that the set timeout is actually being used. Edit: Seeing that two tests now fail because of taking too long. Going to continue on this tomorrow. |
@urmahp If you could give it one more review, that would be great. I didn't clean up the commits since this seems to confuse coverage.io quite a lot. I'll do that right before merging. |
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.
Overall it looks very good. I only have a small comment regarding include of ratio in the test, which I believe is not used.
Other than that I feel fine with merging this.
Also deprecated the explicit method for setting up reconnection time.
eae95f3
to
174e0b5
Compare
This continues #141 and fixes #140.
ToDo: