Skip to content

chore: implement sync.Pool for badge generator#155

Open
kashalls wants to merge 3 commits intomainfrom
badge-threadsafe
Open

chore: implement sync.Pool for badge generator#155
kashalls wants to merge 3 commits intomainfrom
badge-threadsafe

Conversation

@kashalls
Copy link
Copy Markdown
Owner

@kashalls kashalls commented Mar 5, 2026

This also fixes an issue where an value of 10 would match ranges [10,20] instead of [0,10].

@kashalls
Copy link
Copy Markdown
Owner Author

Code review

Found 1 issue:

  1. GetColorConfig silently changes from first-match to last-match semantics. The iteration was changed from a forward range loop to a reverse index loop, meaning when a metric value falls within multiple overlapping color ranges, the last defined range now wins instead of the first. This is an undocumented behavioral change bundled into a sync.Pool performance PR — users with configs relying on range priority ordering will silently get different colors.

func GetColorConfig(colors []configuration.MetricColor, value float64) configuration.MetricColor {
for i := len(colors) - 1; i >= 0; i-- {
colorConfig := colors[i]
if value >= colorConfig.Min && value <= colorConfig.Max {
return colorConfig
}
}

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

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.

1 participant