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

Support fetch command to retrieve many hosts #112

Merged
merged 2 commits into from
Sep 14, 2017
Merged

Conversation

itchyny
Copy link
Contributor

@itchyny itchyny commented Sep 13, 2017

This pull request fixes mkr fetch command to fetch huge number of hosts per one command.

@@ -453,6 +453,17 @@ func doThrow(c *cli.Context) error {
return nil
}

func split(ids []string, count int) [][]string {
xs := make([][]string, 0, (len(ids)+count-1)/count)
Copy link
Contributor

Choose a reason for hiding this comment

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

Panics when count == 0, but it should not happen..

commands.go Outdated
for _, hostIds := range split(argHostIDs, 100) {
metricValues, err := newMackerelFromContext(c).FetchLatestMetricValues(hostIds, optMetricNames)
logger.DieIf(err)
for metricName := range metricValues {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit]
The key of LatestMetricValues is actually hostId, not metricName.
(As long as mkr and mackerel-client-go's definition, it's perfectly unknown what key of LatestMetricValues is, so imo it's good to use some ambiguous name like key...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure.

@itchyny
Copy link
Contributor Author

itchyny commented Sep 14, 2017

Thanks!

@itchyny itchyny merged commit 756caec into master Sep 14, 2017
@itchyny itchyny deleted the mkr-fetch-many-hosts branch September 14, 2017 01:54
@syou6162 syou6162 mentioned this pull request Sep 20, 2017
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.

None yet

2 participants