-
Notifications
You must be signed in to change notification settings - Fork 525
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 reconnect support to eventbus (default off) with onreconnect event #660
Conversation
Should this file used in tests be replaced as well? https://github.com/vert-x3/vertx-web/blob/12d681c8da166092ca24b09d7da9a83f8469e47f/vertx-sockjs-service-proxy/src/test/resources/vertx-js/vertx-eventbus.js Also, I currently don't see any docs for pingEnabled (and so there's no obvious place to add them for reconnectEnabled). Thoughts about that? |
@@ -308,6 +340,16 @@ | |||
} | |||
}; | |||
|
|||
EventBus.prototype.reconnectEnabled = function (enable) { |
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 think the reverse name would be better: enableReconnect
so it sound more natural when you read the code:
on the eventbus
will set enable
reconnect
to true
if you know what i mean...
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 was thinking the same when I wrote this, but there's already an exposed method called pingEnabled which I thought to match.
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 think we should rename that too.
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.
Committed 36c177e, although this is a breaking change, I highly doubt that anybody has ever used the pingEnabled method previously (it's definitely not common)
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.
Breaking changes are acceptable in 3.5.0 - as soon as they are listed.
@yunyu I think we should get rid of the test file and just use one all over the place, otherwise we're not testing it, right? and if you could also add a test for ping it would be great too! |
@pmlopes I'm not sure how to make the service proxy tests use the resource file from the main project 😞 The tests are currently structured to cover the basic things (sending messages over the bus), I'm not sure how ping tests could be added to the existing framework (since it's hard to test for a lack of something). I think I know how to add a test for reconnect, however. |
When running the tests, it seems like the service proxy copies the JS file over from vertx-web. I guess it's not that big of a problem if it's automatically replaced. The only caveat is that the tests are run with the eventbus file before it's replaced, which will cause tests to fail the first time for anything that uses new/breaking features (but work the second time). I don't know enough about how the current POM is set up to fix that, unfortunately. The easiest way to check is by first installing the vertx-web submodule under my branch into the local Maven repositiory (important), replacing the vertx-eventbus.js under the service proxy tests (also under my branch) with the previous/current one, and then running the tests for the service proxy twice. They will fail the first time and succeed the second time. Also, currently calling EventBus.close() still makes the reconnect occur if it's enabled. Should that be the case? (Can't do an inline comment because it's not in the diff). |
@cescoffier can you use your maven magic skills to assist @yunyu ? |
So, right now the vertx-eventbus.js used in the tests of the sockjs-service-proxy is pulled from the vertx-web project (so will only work if this one has been installed). I believe this is fine. What's not great is to have this vertx-eventbus.js in the source tree of the sockjs-service-proxy. This can be easily fixed. So this PR can be merged as it is, and I can get rid of the duplicated file. |
The problem seems to be that the file is copied after the tests are run, so the tests would fail the first time. |
@yunyu Apply this to the project:
And remove Notice that you must have installed the right version in your maven repo first (so mvn clean install from vertx-web). |
Cool, that worked! I assume it cleans out the test output dir after finishing the tests. |
bb8f352
to
f934644
Compare
@yunyu @pmlopes it was just a missuse of the maven lifecycle and test classloading. Tests load the files from It was a build process bug. |
I adapted the backoff from https://github.com/mokesmokes/backo, which is what Socket.io is using. I think this is ready to merge at this point, the only thing missing is a ping test (which wasn't there earlier, and I'm not so sure if the lack of ping is easily testable). |
Also removes eventbus JS from service proxy tests per @cescoffier, renames pingEnabled to enablePing, adds enableReconnect method
onclose event is called after the max reconnect attempts are reached and the last attempt fails
@pmlopes WDYT ? I think it can be part of the 3.5.0 Beta 1 so we can have feedback? |
👍 |
There should also be docs added sometime for the options. All of them have equivalents in Socket.io's manager script. |
@yunyu Thanks! |
Moved from vert-x3/vertx-bus-bower#10
Adapted from https://stackoverflow.com/a/28497938. I've tested it in several scenarios and it seems to be reliable and doesn't cause stack overflows (tested with interval 10ms). The default behavior has no change from previous versions.
Fixes vert-x3/issues#152