Skip to content

Conversation

@majiayu000
Copy link
Contributor

Summary

This PR fixes #96

Changes

  • valkeycompat/adapter.go
  • valkeycompat/adapter_option_test.go

Add AdapterOption type and WithNodeScaleoutLimit functional option
to allow configuring the maximum parallelism for node scaleout
operations in NewAdapter. This addresses issue valkey-io#96 where maxp was
being set incorrectly without user control.

Fixes valkey-io#96

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: majiayu000 <[email protected]>
// If not set, defaults to runtime.GOMAXPROCS(0).
func WithNodeScaleoutLimit(limit int) AdapterOption {
return func(c *Compat) {
c.maxp = limit
Copy link
Collaborator

Choose a reason for hiding this comment

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

We many need to avoid it from being set to less than 1.

@majiayu000
Copy link
Contributor Author

Fixed. Values less than 1 will now default to 1.

@codecov-commenter
Copy link

codecov-commenter commented Dec 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.22%. Comparing base (6677207) to head (03d5ab1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #102      +/-   ##
==========================================
+ Coverage   94.72%   95.22%   +0.49%     
==========================================
  Files          99       99              
  Lines       46876    44109    -2767     
==========================================
- Hits        44404    42002    -2402     
+ Misses       2090     1723     -367     
- Partials      382      384       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #96 by adding the ability to configure the maximum parallelism (maxp) for node scaleout operations in the valkeycompat adapter through a functional options pattern.

Key Changes:

  • Introduces AdapterOption type and WithNodeScaleoutLimit option function for configuring maxp
  • Maintains backward compatibility by using variadic options with sensible defaults
  • Adds comprehensive test coverage for default behavior, option application, and edge cases

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
valkeycompat/adapter.go Implements functional options pattern for NewAdapter, adds WithNodeScaleoutLimit option with validation to ensure values ≥ 1
valkeycompat/adapter_option_test.go Adds comprehensive test suite covering default behavior, option setting, multiple options, and edge case handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@rueian rueian left a comment

Choose a reason for hiding this comment

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

Thanks!

@rueian rueian merged commit 05f746d into valkey-io:main Dec 31, 2025
29 checks passed
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.

valkeycompat NewAdapter sets maxp incorrectly

3 participants