Skip to content

Consolidate redundant command implementations into BaseClient - #498

Open
currantw wants to merge 3 commits into
valkey-io:mainfrom
currantw:462-redundant-implementations
Open

Consolidate redundant command implementations into BaseClient#498
currantw wants to merge 3 commits into
valkey-io:mainfrom
currantw:462-redundant-implementations

Conversation

@currantw

Copy link
Copy Markdown
Collaborator

Summary

Consolidates redundant command implementations into BaseClient and fixes incorrect default routing in cluster mode. Commands that were declared abstract on BaseClient and overridden identically in both GlideClient and GlideClusterClient are now concrete methods in BaseClient, eliminating duplication.

Issue Link

Closes #462.
Closes #491.
Closes #492.
Closes #493.
Closes #494.

Features and Behaviour Changes

Implementation

  • 19 connection/server management commands moved from abstract+override to concrete in BaseClient
  • GlideClient.ConnectionManagementCommands.cs deleted (all methods now in BaseClient)
  • Removed redundant override keywords from GlideClient.ServerManagementCommands.cs and GlideClusterClient.ServerManagementCommands.cs
  • Simplified ToClusterValue() — removed isSingleValue parameter; handler now dynamically detects single vs multi-node responses
  • Inlined MakeClusterValueHandler into Cmd.ToClusterValue() and removed from ResponseConverters
  • GetServerVersionAsync in cluster client now uses default routing (no explicit route)

Limitations

Testing

No updates to testing. Existing test are sufficient.

Related Issues

Checklist

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated and all checks pass.
  • CHANGELOG.md, README.md, DEVELOPER.md, and other documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.
  • All TODOs referencing issue(s) closed by this PR have been resolved.

@currantw currantw self-assigned this Jul 30, 2026
…BaseClient (valkey-io#462)

- Move 19 connection/server management commands from abstract+override
  pattern to concrete implementations in BaseClient
- Fix incorrect cluster routing:
  - SELECT: Random → AllNodes (valkey-io#491)
  - CONFIG SET: AllPrimaries → AllNodes (valkey-io#492)
  - CONFIG REWRITE: Random → AllNodes (valkey-io#493)
  - CONFIG RESETSTAT: AllPrimaries → AllNodes (valkey-io#493)
  - FUNCTION KILL: AllPrimaries → AllNodes (valkey-io#494)
- Remove isSingleValue parameter from ToClusterValue; inline
  MakeClusterValueHandler into Cmd.ToClusterValue()
- Update GetServerVersionAsync to use default routing
- Mark deprecated methods for removal in 2.0 (valkey-io#495, valkey-io#496):
  - ConfigGetAsync(ValkeyValue): use routed overload instead
  - FunctionListAsync(FunctionListOptions?): use routed overload instead
  - ScriptInvokeAsync(Script, ClusterScriptOptions): wrong design
  - ClusterScriptOptions: remove in favor of ScriptOptions
- Delete GlideClient.ConnectionManagementCommands.cs

Signed-off-by: Taylor Curran <taylorcurran@outlook.com>
Signed-off-by: currantw <taylor.curran@improving.com>
@currantw
currantw force-pushed the 462-redundant-implementations branch from 6254d53 to 1a24e7f Compare July 30, 2026 22:00
@currantw
currantw requested a review from Copilot July 31, 2026 02:07

Copilot AI left a comment

Copy link
Copy Markdown

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 refactors the C# client command surface by moving previously duplicated connection/server management command implementations into BaseClient, while also correcting several cluster-routing defaults by relying on glide-core’s built-in routing.

Changes:

  • Consolidated previously abstract + duplicated overrides into concrete BaseClient implementations (reducing duplication across standalone/cluster clients).
  • Fixed cluster-mode routing for several commands by removing incorrect explicit Route usage and relying on glide-core defaults.
  • Simplified cluster response handling by making Cmd.ToClusterValue() infer single-vs-multi from the response shape.

Reviewed changes

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

Show a summary per file
File Description
tests/Valkey.Glide.UnitTests/PubSubThreadSafetyTests.cs Removes now-unneeded mock overrides after BaseClient consolidation.
tests/Valkey.Glide.UnitTests/PubSubFFIIntegrationTests.cs Removes now-unneeded mock overrides after BaseClient consolidation.
tests/Valkey.Glide.UnitTests/ClusterScriptOptionsTests.cs Suppresses obsolete warnings for ClusterScriptOptions tests pending removal.
tests/Valkey.Glide.IntegrationTests/ServerManagementCommandTests.cs Adds targeted CS0618 suppression for deprecated cluster APIs.
tests/Valkey.Glide.IntegrationTests/ClusterClientTests.cs Adds targeted CS0618 suppression for deprecated cluster APIs.
sources/Valkey.Glide/scripting/ClusterScriptOptions.cs Marks ClusterScriptOptions as obsolete with removal guidance.
sources/Valkey.Glide/Internals/ResponseConverters.cs Removes now-inlined MakeClusterValueHandler.
sources/Valkey.Glide/Internals/Request.ConnectionManagement.cs Removes route-specific ClientGetName builder; uses ToClusterValue() at call sites.
sources/Valkey.Glide/Internals/Cmd.cs Reworks ToClusterValue() to detect multi-node responses by runtime type.
sources/Valkey.Glide/Client/IGlideClusterClient.ServerManagementCommands.cs Deprecates legacy no-route ConfigGetAsync overload.
sources/Valkey.Glide/Client/IGlideClusterClient.ScriptingAndFunctionCommands.cs Deprecates legacy script/function APIs pending redesign.
sources/Valkey.Glide/Client/GlideClusterClient.ServerManagementCommands.cs Removes redundant routing/override patterns; relies on glide-core defaults.
sources/Valkey.Glide/Client/GlideClusterClient.ScriptingAndFunctionCommands.cs Updates cluster scripting/function commands to new ToClusterValue() usage.
sources/Valkey.Glide/Client/GlideClusterClient.cs Updates server-version retrieval to use default routing and handle multi-node responses.
sources/Valkey.Glide/Client/GlideClusterClient.ConnectionManagementCommands.cs Removes duplicated no-route overrides now provided by BaseClient.
sources/Valkey.Glide/Client/GlideClient.ServerManagementCommands.cs Removes redundant overrides now implemented in BaseClient.
sources/Valkey.Glide/Client/GlideClient.ConnectionManagementCommands.cs Deletes duplicated command implementation file (moved to BaseClient).
sources/Valkey.Glide/Client/BaseClient.ServerManagementCommands.cs Implements consolidated server-management commands in the base class.
sources/Valkey.Glide/Client/BaseClient.ConnectionManagementCommands.cs Implements consolidated connection-management commands in the base class.
CHANGELOG.md Documents routing fixes for cluster mode.

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

Comment thread sources/Valkey.Glide/Internals/Cmd.cs
Comment thread sources/Valkey.Glide/Client/GlideClusterClient.ServerManagementCommands.cs Outdated
currantw added 2 commits July 30, 2026 19:33
Signed-off-by: currantw <taylor.curran@improving.com>
…responses

When a SingleNodeRoute is used, glide-core returns a raw value (not
wrapped in a multi-node dictionary). Commands whose raw response type
is itself a dictionary (e.g. MemoryStats) were incorrectly detected
as multi-node responses. ToClusterValue(Route) skips dictionary
detection for single-node routes.

Signed-off-by: Taylor Curran <taylorcurran@outlook.com>
Signed-off-by: currantw <taylor.curran@improving.com>
@currantw currantw added this to the 1.2 milestone Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment