Skip to content
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

FIX #103 - Implementing discovered servers API #143

Merged
merged 1 commit into from
May 5, 2017
Merged

Conversation

aricart
Copy link
Member

@aricart aricart commented May 4, 2017

Extended nats_server_control to allow easy creation of a cluster
Bumped versions

@coveralls
Copy link

coveralls commented May 4, 2017

Coverage Status

Coverage increased (+0.8%) to 95.652% when pulling b5db73e on discovered-servers into 6eba3ea on master.

@aricart aricart requested a review from kozlovic May 4, 2017 19:43
@@ -797,6 +801,23 @@ Client.prototype.processInbound = function() {
if (client.checkTLSMismatch() === true) {
return;
}

// Always try to read the connect_urls from info
if(client.info.connect_urls && client.info.connect_urls.length > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, indentation looks strange.
Second, are you not going to do that for any protocol message received by the client? Looks to me that you should ensure that protocol being processed is an INFO here.
Also, not sure if you support randomization, but what the other clients do is randomize (if allowed) the array or connect_urls prior to add the URLs to the server pool.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I preserved the indentation that was in the file :)
The block we are in is only handling INFO messages. See https://sourcegraph.com/github.com/nats-io/node-nats@b5db73ee06428471568a730c3b0ff7f907fa6943/-/blob/lib/nats.js#L798:1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even with this link, I am sorry but it looks horrible. It is very difficult to know what is in which block.

lib/nats.js Outdated
client.info.connect_urls.forEach(function(server) {
var u = 'nats://' + server;
if(known.indexOf(u) === -1) {
client.addServer(u);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this do the right thing with randomizing or not the list?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, we don't want to randomize the pool when we add things after the initial connect. We can randomize the received URLs before adding to the pool, but not randomize the entire pool after initial connect.

});
});

it('setting protocol zero doesnt update', function(done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to expose and let client decide? Is that how we do it in other clients, they can suppress if they want to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove the option.

// add two servers
process.nextTick(function () {
var others = nsc.add_member_with_delay([port + 1, port + 2], route_port, 250, function () {
should(others.length).be.equal(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should write test to check randomize etc. And not randomize.

@coveralls
Copy link

coveralls commented May 4, 2017

Coverage Status

Coverage increased (+0.8%) to 95.668% when pulling dec737a on discovered-servers into 6eba3ea on master.

@coveralls
Copy link

coveralls commented May 4, 2017

Coverage Status

Coverage increased (+0.8%) to 95.668% when pulling 175d828 on discovered-servers into 6eba3ea on master.

@aricart
Copy link
Member Author

aricart commented May 5, 2017

@kozlovic @derekcollison I have put in the changes. protocol option is removed. Shuffling of the discovered servers is done and then appended to the current list and an associated test. The code formatting issue, I would like to tackle under #144. Note that doing so will dump the blame history, but that thread can be discussed there.

@derekcollison
Copy link
Member

LGTM, let's have @kozlovic give a +1 as well.

Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the array should be shuffled only if allowed.

lib/nats.js Outdated
});

if(toAdd.length > 0) {
shuffle(toAdd);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken, this client has a noRandomize option. If so, you should shuffle the incoming array only if noRandomize === false.

Added test
Extended nats_server_control to allow easy creation of a cluster
Bumped versions
@coveralls
Copy link

Coverage Status

Coverage increased (+0.9%) to 95.676% when pulling 6fd8397 on discovered-servers into 6eba3ea on master.

@aricart
Copy link
Member Author

aricart commented May 5, 2017

@kozlovic I made the shuffling of the discovered servers honor noRandomize, and added a related test.

@kozlovic
Copy link
Member

kozlovic commented May 5, 2017

LGTM. Not sure why we get so many coveralls report (I deleted some from this page).

@aricart
Copy link
Member Author

aricart commented May 5, 2017 via email

@aricart aricart merged commit 25cddf6 into master May 5, 2017
@aricart aricart deleted the discovered-servers branch May 5, 2017 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants