-
Notifications
You must be signed in to change notification settings - Fork 2
Reconnection support #12
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
Conversation
peiyush13
commented
Jul 5, 2018
- Added Reconnection Support as per the issue :- Reconnection support :) #9
b52baee to
446500a
Compare
b52baee to
446500a
Compare
e82357c to
8018096
Compare
8018096 to
0022ddb
Compare
Added reconnection strategy for socketclusterclient
0022ddb to
5ba021d
Compare
| include DataModels | ||
| include Reconnect | ||
|
|
||
| attr_accessor :reconnect_interval, :max_reconnect_interval, :reconnect_decay, :max_attempts, :attempts_made |
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.
Don't need to add attr_accessor for variables used in the class itself and unless we are using strong params.
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.
- attr_accessors are used here to avoid unnecessary for getter-setter methods, strong params are not applicable here
README.md
Outdated
| ``` | ||
|
|
||
| - For disabling reconnection to server | ||
| - To disable Automatic Reconnection |
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.
Please change it to: To disable automatic reconnection to server
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.
done
lib/socketclusterclient/reconnect.rb
Outdated
| def reconnection_attempts_finished | ||
| return @attempts_made == @max_attempts | ||
| end | ||
|
|
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.
Remove this line, or else run rubocop --autocorrect which will fix this issue.
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.
done
| # | ||
| # | ||
| def set_reconnection_listener(reconnect_interval, max_reconnect_interval, reconnect_decay, max_attempts) | ||
| @max_reconnect_interval = max_reconnect_interval |
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.
Please put this line below as it changes the code output. Refer: https://github.com/sacOO7/socketcluster-client-java/blob/master/src/main/java/io/github/sac/ReconnectStrategy.java
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.
It is not needed as the logical bug here but for the sake of micro optimisation, I am changing it.
lib/socketclusterclient/reconnect.rb
Outdated
| # | ||
| # Module Reconnect provides Reconnection Support | ||
| # | ||
| # @author Piyush Wani <piyush.wani@amuratech.com> |
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.
Change email to your github email_id
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.
ok thanks
| # | ||
| # @author Piyush Wani <piyush.wani@amuratech.com> | ||
| # | ||
| module 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.
Please run: rubocop --autocorrect
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.
done
| socket.connect | ||
| socket.set_reconnection(false) # default reconnection is true | ||
| socket.max_attempts = 5 | ||
| socket.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.
Can we also add an example, if we set_reconnection to true?
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.
set_reconnction method is for automatic reconnection and one should not manually reconnect if auto_reconnection is enabled. so no need to add an example for that
Changed code as per the Rubocop generated suggestions