Skip to content

Commit

Permalink
added exposed types for GlideClient
Browse files Browse the repository at this point in the history
  • Loading branch information
edlng committed Jan 20, 2025
1 parent acff29c commit c1cccbb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion go/api/base_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"google.golang.org/protobuf/proto"
)

// BaseClient defines an interface for methods common to both [GlideClient] and [GlideClusterClient].
// BaseClient defines an interface for methods common to both [IGlideClient] and [GlideClusterClient].
type BaseClient interface {
StringCommands
HashCommands
Expand Down
24 changes: 12 additions & 12 deletions go/api/glide_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,55 @@ import (
)

// GlideClient interface compliance check.
var _ GlideClient = (*glideClient)(nil)
var _ IGlideClient = (*GlideClient)(nil)

// GlideClient is a client used for connection in Standalone mode.
type GlideClient interface {
// IGlideClient is a client used for connection in Standalone mode.
type IGlideClient interface {
BaseClient
GenericCommands
ServerManagementCommands
}

// glideClient implements standalone mode operations by extending baseClient functionality.
type glideClient struct {
// GlideClient implements standalone mode operations by extending baseClient functionality.
type GlideClient struct {
*baseClient
}

// NewGlideClient creates a [GlideClient] in standalone mode using the given [GlideClientConfiguration].
func NewGlideClient(config *GlideClientConfiguration) (GlideClient, error) {
// NewGlideClient creates a [IGlideClient] in standalone mode using the given [GlideClientConfiguration].
func NewGlideClient(config *GlideClientConfiguration) (IGlideClient, error) {
client, err := createClient(config)
if err != nil {
return nil, err
}

return &glideClient{client}, nil
return &GlideClient{client}, nil
}

func (client *glideClient) CustomCommand(args []string) (interface{}, error) {
func (client *GlideClient) CustomCommand(args []string) (interface{}, error) {
res, err := client.executeCommand(C.CustomCommand, args)
if err != nil {
return nil, err
}
return handleInterfaceResponse(res)
}

func (client *glideClient) ConfigSet(parameters map[string]string) (string, error) {
func (client *GlideClient) ConfigSet(parameters map[string]string) (string, error) {
result, err := client.executeCommand(C.ConfigSet, utils.MapToString(parameters))
if err != nil {
return "", err
}
return handleStringResponse(result)
}

func (client *glideClient) ConfigGet(args []string) (map[string]string, error) {
func (client *GlideClient) ConfigGet(args []string) (map[string]string, error) {
res, err := client.executeCommand(C.ConfigGet, args)
if err != nil {
return nil, err
}
return handleStringToStringMapResponse(res)
}

func (client *glideClient) Select(index int64) (string, error) {
func (client *GlideClient) Select(index int64) (string, error) {
result, err := client.executeCommand(C.Select, []string{utils.IntToString(index)})
if err != nil {
return "", err
Expand Down
6 changes: 3 additions & 3 deletions go/integTest/glide_test_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type GlideTestSuite struct {
clusterHosts []api.NodeAddress
tls bool
serverVersion string
clients []api.GlideClient
clients []api.IGlideClient
clusterClients []api.GlideClusterClient
}

Expand Down Expand Up @@ -227,15 +227,15 @@ func (suite *GlideTestSuite) getDefaultClients() []api.BaseClient {
return []api.BaseClient{suite.defaultClient(), suite.defaultClusterClient()}
}

func (suite *GlideTestSuite) defaultClient() api.GlideClient {
func (suite *GlideTestSuite) defaultClient() api.IGlideClient {
config := api.NewGlideClientConfiguration().
WithAddress(&suite.standaloneHosts[0]).
WithUseTLS(suite.tls).
WithRequestTimeout(5000)
return suite.client(config)
}

func (suite *GlideTestSuite) client(config *api.GlideClientConfiguration) api.GlideClient {
func (suite *GlideTestSuite) client(config *api.GlideClientConfiguration) api.IGlideClient {
client, err := api.NewGlideClient(config)

assert.Nil(suite.T(), err)
Expand Down
12 changes: 6 additions & 6 deletions go/integTest/shared_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4098,7 +4098,7 @@ func sendWithCustomCommand(suite *GlideTestSuite, client api.BaseClient, args []
var res any
var err error
switch c := client.(type) {
case api.GlideClient:
case api.IGlideClient:
res, err = c.CustomCommand(args)
case api.GlideClusterClient:
res, err = c.CustomCommand(args)
Expand Down Expand Up @@ -4396,7 +4396,7 @@ func (suite *GlideTestSuite) TestXRead() {

// ensure that commands doesn't time out even if timeout > request timeout
var testClient api.BaseClient
if _, ok := client.(api.GlideClient); ok {
if _, ok := client.(api.IGlideClient); ok {
testClient = suite.client(api.NewGlideClientConfiguration().
WithAddress(&suite.standaloneHosts[0]).
WithUseTLS(suite.tls))
Expand Down Expand Up @@ -5412,7 +5412,7 @@ func (suite *GlideTestSuite) TestXPending() {
// each use of CustomCommand would make the tests difficult to read and maintain. These tests can be
// collapsed once the native commands are added in a subsequent release.

execStandalone := func(client api.GlideClient) {
execStandalone := func(client api.IGlideClient) {
// 1. Arrange the data
key := uuid.New().String()
groupName := "group" + uuid.New().String()
Expand Down Expand Up @@ -5568,7 +5568,7 @@ func (suite *GlideTestSuite) TestXPending() {
// this is only needed in order to be able to use custom commands.
// Once the native commands are added, this logic will be refactored.
switch c := client.(type) {
case api.GlideClient:
case api.IGlideClient:
execStandalone(c)
case api.GlideClusterClient:
execCluster(c)
Expand All @@ -5586,7 +5586,7 @@ func (suite *GlideTestSuite) TestXPendingFailures() {
// each use of CustomCommand would make the tests difficult to read and maintain. These tests can be
// collapsed once the native commands are added in a subsequent release.

execStandalone := func(client api.GlideClient) {
execStandalone := func(client api.IGlideClient) {
// 1. Arrange the data
key := uuid.New().String()
missingKey := uuid.New().String()
Expand Down Expand Up @@ -5892,7 +5892,7 @@ func (suite *GlideTestSuite) TestXPendingFailures() {
// this is only needed in order to be able to use custom commands.
// Once the native commands are added, this logic will be refactored.
switch c := client.(type) {
case api.GlideClient:
case api.IGlideClient:
execStandalone(c)
case api.GlideClusterClient:
execCluster(c)
Expand Down

0 comments on commit c1cccbb

Please sign in to comment.