go: Expose common client interfaces (BaseClientCommands, GlideClientCommands, etc.) for testing and abstraction
Describe the feature
Summary
Currently, the valkey-glide/go/v2/internal/interfaces package defines several useful interfaces such as:
BaseClientCommandsGlideClientCommandsGlideClusterClientCommands
However, these interfaces are internal and cannot be imported or used by external projects.
I'd like them to be available from our applications.
Use Case
In real-world applications, developers often need to write code that supports both standalone and cluster modes of Valkey through a unified abstraction layer. This is especially important in scenarios such as:
- Running unit tests using miniredis or a custom mock client while using
glide.ClusterClientin production. - Injecting a generic client via dependency inversion for better testability and separation of concerns.
- Sharing logic between standalone and cluster environments without duplicating command calls.
Currently, because the interfaces are internal, developers must redefine their own local equivalents to achieve this. This leads to unnecessary duplication, potential incompatibility with future Glide updates, and a more difficult testing setup.
Proposed Solution
We propose that the Valkey Glide project expose these interfaces (or a subset thereof) in a public package, for example:
- Move
internal/interfaces→go/v2/interfaces, or - Introduce a minimal shared interface such as:
type CommonClient interface {
interfaces.StringCommands
interfaces.HashCommands
interfaces.ListCommands
interfaces.SetCommands
interfaces.StreamCommands
interfaces.SortedSetCommands
interfaces.HyperLogLogCommands
interfaces.GenericBaseCommands
interfaces.BitmapCommands
interfaces.GeoSpatialCommands
interfaces.ScriptingAndFunctionBaseCommands
interfaces.PubSubCommands
}
This would enable developers to write reusable code and easily plug in either glide.Client, glide.ClusterClient, or test doubles.
Other Information
No response
Acknowledgements
- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
Client version used
v2.1.1
Environment details (OS name and version, etc.)
macOS
Hi @mickamy , thank you for creating this issue!
@prateek-kumar-improving , I remember you designed this part. WDYT?