diff --git a/go/api/config/request_routing_config.go b/go/api/config/request_routing_config.go index 154fcc8ee3..47c3d7877a 100644 --- a/go/api/config/request_routing_config.go +++ b/go/api/config/request_routing_config.go @@ -21,6 +21,9 @@ type Route interface { IsMultiNode() bool } +type notMultiNode struct{} +func (_ *notMultiNode) IsMultiNode() bool { return false } + type SimpleNodeRoute int const ( @@ -96,6 +99,7 @@ func mapSlotType(slotType SlotType) (protobuf.SlotTypes, error) { type SlotIdRoute struct { slotType SlotType slotID int32 + notMultiNode } // - slotType: Defines type of the node being addressed. @@ -122,15 +126,12 @@ func (slotIdRoute *SlotIdRoute) ToRoutesProtobuf() (*protobuf.Routes, error) { return request, nil } -func (route *SlotIdRoute) IsMultiNode() bool { - return false -} - // Request routing configuration overrides the [api.ReadFrom] connection configuration. // If SlotTypeReplica is used, the request will be routed to a replica, even if the strategy is ReadFrom [api.PreferReplica]. type SlotKeyRoute struct { slotType SlotType slotKey string + notMultiNode } // - slotType: Defines type of the node being addressed. @@ -156,14 +157,12 @@ func (slotKeyRoute *SlotKeyRoute) ToRoutesProtobuf() (*protobuf.Routes, error) { return request, nil } -func (route *SlotKeyRoute) IsMultiNode() bool { - return false -} // Routes a request to a node by its address. type ByAddressRoute struct { host string port int32 + notMultiNode } // Create a route using hostname/address and port. @@ -208,7 +207,3 @@ func (byAddressRoute *ByAddressRoute) ToRoutesProtobuf() (*protobuf.Routes, erro } return request, nil } - -func (route *ByAddressRoute) IsMultiNode() bool { - return false -} diff --git a/go/integTest/cluster_commands_test.go b/go/integTest/cluster_commands_test.go index 1aafad40b8..50693b5b17 100644 --- a/go/integTest/cluster_commands_test.go +++ b/go/integTest/cluster_commands_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/valkey-io/valkey-glide/go/glide/api" + "github.com/valkey-io/valkey-glide/go/glide/api/config" ) func (suite *GlideTestSuite) TestClusterCustomCommandInfo() { @@ -77,7 +78,7 @@ func (suite *GlideTestSuite) TestInfoCluster() { // same sections with random route opts = api.ClusterInfoOptions{ InfoOptions: &api.InfoOptions{Sections: sections}, - Route: api.RandomRoute.ToPtr(), + Route: config.RandomRoute.ToPtr(), } response, err = client.InfoWithOptions(opts) assert.NoError(t, err) @@ -94,7 +95,7 @@ func (suite *GlideTestSuite) TestInfoCluster() { // default sections, multi node route opts = api.ClusterInfoOptions{ InfoOptions: nil, - Route: api.AllPrimaries.ToPtr(), + Route: config.AllPrimaries.ToPtr(), } response, err = client.InfoWithOptions(opts) assert.NoError(t, err) diff --git a/go/integTest/glide_test_suite_test.go b/go/integTest/glide_test_suite_test.go index 2676926591..b6dc71032f 100644 --- a/go/integTest/glide_test_suite_test.go +++ b/go/integTest/glide_test_suite_test.go @@ -16,6 +16,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "github.com/valkey-io/valkey-glide/go/glide/api" + "github.com/valkey-io/valkey-glide/go/glide/api/config" ) type GlideTestSuite struct { @@ -141,12 +142,12 @@ func runClusterManager(suite *GlideTestSuite, args []string, ignoreExitCode bool func getServerVersion(suite *GlideTestSuite) string { var err error = nil if len(suite.standaloneHosts) > 0 { - config := api.NewGlideClientConfiguration(). + clientConfig := api.NewGlideClientConfiguration(). WithAddress(&suite.standaloneHosts[0]). WithUseTLS(suite.tls). WithRequestTimeout(5000) - client, err := api.NewGlideClient(config) + client, err := api.NewGlideClient(clientConfig) if err == nil && client != nil { defer client.Close() info, _ := client.InfoWithOptions(api.InfoOptions{Sections: []api.Section{api.Server}}) @@ -160,19 +161,19 @@ func getServerVersion(suite *GlideTestSuite) string { suite.T().Fatal("No server hosts configured") } - config := api.NewGlideClusterClientConfiguration(). + clientConfig := api.NewGlideClusterClientConfiguration(). WithAddress(&suite.clusterHosts[0]). WithUseTLS(suite.tls). WithRequestTimeout(5000) - client, err := api.NewGlideClusterClient(config) + client, err := api.NewGlideClusterClient(clientConfig) if err == nil && client != nil { defer client.Close() info, _ := client.InfoWithOptions( api.ClusterInfoOptions{ InfoOptions: &api.InfoOptions{Sections: []api.Section{api.Server}}, - Route: api.RandomRoute.ToPtr(), + Route: config.RandomRoute.ToPtr(), }, ) return extractServerVersion(suite, info.SingleValue())