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

ListGroups and DescribeGroups protocol #770

Merged
merged 9 commits into from
Oct 5, 2017
Merged

Conversation

wooyeong
Copy link
Contributor

@wooyeong
Copy link
Contributor Author

Oh, I think correlationId and request object should go inside mapValuesSeries before this.queueCallback. I'll fix it.

// removing {error: null} before merging
results = _.map(results, result => _.omitBy(result, _.isNull));

callback(null, _.merge({}, ...(_.values(results))));
Copy link
Collaborator

@hyperlink hyperlink Sep 20, 2017

Choose a reason for hiding this comment

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

We are still supporting node 4 so spread can't be used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change it to use .apply instead

this.queueCallback(broker.socket, correlationId, [
protocol.decodeListGroups,
cb,
this.options.versions.requestTimeout
Copy link
Collaborator

Choose a reason for hiding this comment

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

this can be omitted if using the default requestTimeout value.

return callback(new Error('Client is not ready (getListGroups)'));
}
const brokers = this.brokerMetadata;
async.mapValuesSeries(brokers,
Copy link
Collaborator

@hyperlink hyperlink Sep 20, 2017

Choose a reason for hiding this comment

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

Series is not need here since there's no ordering requirement on the result correct? Lets we change this to mapValuesLimit instead with a default (configurable) limit of 10.

if (!this.ready) {
return callback(new Error('Client is not ready (getDescribeGroups)'));
}
const self = this;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is setting self necessary since we're using fat arrows throughout?

return;
}

async.mapValuesSeries(results,
Copy link
Collaborator

Choose a reason for hiding this comment

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

mapValuesLimit ?

this.queueCallback(broker.socket, correlationId, [
protocol.decodeDescribeGroups,
cb,
this.options.versions.requestTimeout
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment as above this is optional.

Copy link
Collaborator

@hyperlink hyperlink left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Any plans to write a test for this?

@wooyeong
Copy link
Contributor Author

I've changed all mentioned problems, and introduced a new option options.maxAsyncRequests which defaults to 10 to feed mapValuesLimit.

For test, I think I can't write tests right now because I have at least minimum working code and have to make service first. I may try in the 1st week of October if it's not done.

(brokerMetadata, brokerId, cb) => {
const broker = this.brokerForLeader(brokerId);
if (!broker || !broker.isConnected()) {
return callback(new errors.BrokerNotAvailableError('Broker not available (getListGroups)'));
Copy link
Collaborator

Choose a reason for hiding this comment

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

callback should be cb here.

return callback(new Error('Client is not ready (getDescribeGroups)'));
}

async.groupBy(groups,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we use groupByLimit here instead?

(groups, coordinator, cb) => {
const broker = this.brokerForLeader(coordinator);
if (!broker || !broker.isConnected()) {
return callback(new errors.BrokerNotAvailableError('Broker not available (getDescribeGroups)'));
Copy link
Collaborator

@hyperlink hyperlink Sep 21, 2017

Choose a reason for hiding this comment

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

this should be cb here and not that main callback.

broker.write(request);
},
(err, res) => {
callback(err || null, res);
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we flatten the result so it's keyed by groupId?

Copy link
Collaborator

@hyperlink hyperlink left a comment

Choose a reason for hiding this comment

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

Looks much better thanks for the update!

Can you update the README with these new APIs ?

This is optional but you can also create a new Admin wrapper class if so inclined.

@wooyeong
Copy link
Contributor Author

wooyeong commented Oct 5, 2017

Changed as you requested. I also wrote new admin wrapper class and README.

For Admin, I reject if user provides older Client, but I don't know it's recommended way to do so.

@hyperlink hyperlink merged commit c1044c4 into SOHU-Co:master Oct 5, 2017
@hyperlink
Copy link
Collaborator

Thanks for sticking with this @wooyeong ! Great feature 👍

@wooyeong wooyeong deleted the adminapi branch October 5, 2017 14:13
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.

2 participants