Skip to content

Commit

Permalink
performed rebase to pass ci
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Liang <[email protected]>
  • Loading branch information
edlng committed Jan 20, 2025
1 parent a537763 commit a5eda6f
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 356 deletions.
352 changes: 112 additions & 240 deletions go/api/base_client.go

Large diffs are not rendered by default.

18 changes: 0 additions & 18 deletions go/api/connection_management_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,9 @@ package api
//
// [valkey.io]: https://valkey.io/commands/#connection
type ConnectionManagementCommands interface {

Ping() (string, error)

PingWithMessage(message string) (string, error)

// Echo the provided message back.
// The command will be routed a random node.
//
// Parameters:
// message - The provided message.
//
// Return value:
// The provided message
//
// For example:
// result, err := client.Echo("Hello World")
// if err != nil {
// // handle error
// }
// fmt.Println(result.Value()) // Output: Hello World
//
// [valkey.io]: https://valkey.io/commands/echo/
Echo(message string) (Result[string], error)
}
25 changes: 0 additions & 25 deletions go/api/generic_cluster_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,5 @@ package api
//
// [valkey.io]: https://valkey.io/commands/#generic
type GenericClusterCommands interface {
// CustomCommand executes a single command, specified by args, without checking inputs. Every part of the command,
// including the command name and subcommands, should be added as a separate value in args. The returning value depends on
// the executed
// command.
//
// The command will be routed automatically based on the passed command's default request policy.
//
// See [Valkey GLIDE Wiki] for details on the restrictions and limitations of the custom command API.
//
// This function should only be used for single-response commands. Commands that don't return complete response and awaits
// (such as SUBSCRIBE), or that return potentially more than a single response (such as XREAD), or that change the client's
// behavior (such as entering pub/sub mode on RESP2 connections) shouldn't be called using this function.
//
// Parameters:
// args - Arguments for the custom command including the command name.
//
// Return value:
// The returned value for the custom command.
//
// For example:
//
// result, err := client.CustomCommand([]string{"ping"})
// result.Value().(string): "PONG"
//
// [Valkey GLIDE Wiki]: https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command
CustomCommand(args []string) (ClusterValue[interface{}], error)
}
22 changes: 0 additions & 22 deletions go/api/generic_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,5 @@ package api
//
// [valkey.io]: https://valkey.io/commands/#generic
type GenericCommands interface {
// CustomCommand executes a single command, specified by args, without checking inputs. Every part of the command,
// including the command name and subcommands, should be added as a separate value in args. The returning value depends on
// the executed
// command.
//
// See [Valkey GLIDE Wiki] for details on the restrictions and limitations of the custom command API.
//
// This function should only be used for single-response commands. Commands that don't return complete response and awaits
// (such as SUBSCRIBE), or that return potentially more than a single response (such as XREAD), or that change the client's
// behavior (such as entering pub/sub mode on RESP2 connections) shouldn't be called using this function.
//
// Parameters:
// args - Arguments for the custom command including the command name.
//
// Return value:
// The returned value for the custom command.
//
// For example:
// result, err := client.CustomCommand([]string{"ping"})
// result.(string): "PONG"
//
// [Valkey GLIDE Wiki]: https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command
CustomCommand(args []string) (interface{}, error)
}
82 changes: 82 additions & 0 deletions go/api/glide_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,31 @@ func NewGlideClient(config *GlideClientConfiguration) (IGlideClient, error) {
return &GlideClient{client}, nil
}

// CustomCommand executes a single command, specified by args, without checking inputs. Every part of the command,
// including the command name and subcommands, should be added as a separate value in args. The returning value depends on
// the executed
// command.
//
// See [Valkey GLIDE Wiki] for details on the restrictions and limitations of the custom command API.
//
// This function should only be used for single-response commands. Commands that don't return complete response and awaits
// (such as SUBSCRIBE), or that return potentially more than a single response (such as XREAD), or that change the client's
// behavior (such as entering pub/sub mode on RESP2 connections) shouldn't be called using this function.
//
// Parameters:
//
// args - Arguments for the custom command including the command name.
//
// Return value:
//
// The returned value for the custom command.
//
// For example:
//
// result, err := client.CustomCommand([]string{"ping"})
// result.(string): "PONG"
//
// [Valkey GLIDE Wiki]: https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command
func (client *GlideClient) CustomCommand(args []string) (interface{}, error) {
res, err := client.executeCommand(C.CustomCommand, args)
if err != nil {
Expand All @@ -43,6 +68,26 @@ func (client *GlideClient) CustomCommand(args []string) (interface{}, error) {
return handleInterfaceResponse(res)
}

// Sets configuration parameters to the specified values.
//
// Note: Prior to Version 7.0.0, only one parameter can be send.
//
// See [valkey.io] for details.
//
// Parameters:
//
// parameters - A map consisting of configuration parameters and their respective values to set.
//
// Return value:
//
// `"OK"` if all configurations have been successfully set. Otherwise, raises an error.
//
// For example:
//
// result, err := client.ConfigSet(map[string]string{"timeout": "1000", "maxmemory": "1GB"})
// result: "OK"
//
// [valkey.io]: https://valkey.io/commands/config-set/
func (client *GlideClient) ConfigSet(parameters map[string]string) (string, error) {
result, err := client.executeCommand(C.ConfigSet, utils.MapToString(parameters))
if err != nil {
Expand All @@ -51,6 +96,27 @@ func (client *GlideClient) ConfigSet(parameters map[string]string) (string, erro
return handleStringResponse(result)
}

// Gets the values of configuration parameters.
//
// Note: Prior to Version 7.0.0, only one parameter can be send.
//
// See [valkey.io] for details.
//
// Parameters:
//
// args - A slice of configuration parameter names to retrieve values for.
//
// Return value:
//
// A map of api.Result[string] corresponding to the configuration parameters.
//
// For example:
//
// result, err := client.ConfigGet([]string{"timeout" , "maxmemory"})
// // result["timeout"] = "1000"
// // result["maxmemory"] = "1GB"
//
// [valkey.io]: https://valkey.io/commands/config-get/
func (client *GlideClient) ConfigGet(args []string) (map[string]string, error) {
res, err := client.executeCommand(C.ConfigGet, args)
if err != nil {
Expand All @@ -59,6 +125,22 @@ func (client *GlideClient) ConfigGet(args []string) (map[string]string, error) {
return handleStringToStringMapResponse(res)
}

// Select changes the currently selected database.
//
// Parameters:
//
// index - The index of the database to select.
//
// Return value:
//
// A simple `"OK"` response.
//
// Example:
//
// result, err := client.Select(2)
// result: "OK"
//
// [valkey.io]: https://valkey.io/commands/select/
func (client *GlideClient) Select(index int64) (string, error) {
result, err := client.executeCommand(C.Select, []string{utils.IntToString(index)})
if err != nil {
Expand Down
27 changes: 27 additions & 0 deletions go/api/glide_cluster_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ func NewGlideClusterClient(config *GlideClusterClientConfiguration) (GlideCluste
return &glideClusterClient{client}, nil
}

// CustomCommand executes a single command, specified by args, without checking inputs. Every part of the command,
// including the command name and subcommands, should be added as a separate value in args. The returning value depends on
// the executed
// command.
//
// The command will be routed automatically based on the passed command's default request policy.
//
// See [Valkey GLIDE Wiki] for details on the restrictions and limitations of the custom command API.
//
// This function should only be used for single-response commands. Commands that don't return complete response and awaits
// (such as SUBSCRIBE), or that return potentially more than a single response (such as XREAD), or that change the client's
// behavior (such as entering pub/sub mode on RESP2 connections) shouldn't be called using this function.
//
// Parameters:
//
// args - Arguments for the custom command including the command name.
//
// Return value:
//
// The returned value for the custom command.
//
// For example:
//
// result, err := client.CustomCommand([]string{"ping"})
// result.Value().(string): "PONG"
//
// [Valkey GLIDE Wiki]: https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command
func (client *glideClusterClient) CustomCommand(args []string) (ClusterValue[interface{}], error) {
res, err := client.executeCommand(C.CustomCommand, args)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion go/api/hyperloglog_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package api
//
// [valkey.io]: https://valkey.io/commands/#hyperloglog
type HyperLogLogCommands interface {

PfAdd(key string, elements []string) (int64, error)

PfCount(keys []string) (int64, error)
Expand Down
48 changes: 0 additions & 48 deletions go/api/server_management_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,9 @@ package api
//
// [valkey.io]: https://valkey.io/commands/#server
type ServerManagementCommands interface {
// Select changes the currently selected database.
//
// Parameters:
// index - The index of the database to select.
//
// Return value:
// A simple `"OK"` response.
//
// Example:
// result, err := client.Select(2)
// result: "OK"
//
// [valkey.io]: https://valkey.io/commands/select/
Select(index int64) (string, error)

// Gets the values of configuration parameters.
//
// Note: Prior to Version 7.0.0, only one parameter can be send.
//
// See [valkey.io] for details.
//
// Parameters:
// args - A slice of configuration parameter names to retrieve values for.
//
// Return value:
// A map of api.Result[string] corresponding to the configuration parameters.
//
// For example:
// result, err := client.ConfigGet([]string{"timeout" , "maxmemory"})
// // result["timeout"] = "1000"
// // result["maxmemory"] = "1GB"
//
// [valkey.io]: https://valkey.io/commands/config-get/
ConfigGet(args []string) (map[string]string, error)

// Sets configuration parameters to the specified values.
//
// Note: Prior to Version 7.0.0, only one parameter can be send.
//
// See [valkey.io] for details.
//
// Parameters:
// parameters - A map consisting of configuration parameters and their respective values to set.
//
// Return value:
// `"OK"` if all configurations have been successfully set. Otherwise, raises an error.
//
// For example:
// result, err := client.ConfigSet(map[string]string{"timeout": "1000", "maxmemory": "1GB"})
// result: "OK"
//
// [valkey.io]: https://valkey.io/commands/config-set/
ConfigSet(parameters map[string]string) (string, error)
}
1 change: 0 additions & 1 deletion go/api/stream_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import "github.com/valkey-io/valkey-glide/go/glide/api/options"
//
// [valkey.io]: https://valkey.io/commands/#stream
type StreamCommands interface {

XAdd(key string, values [][]string) (Result[string], error)

XAddWithOptions(key string, values [][]string, options *options.XAddOptions) (Result[string], error)
Expand Down
1 change: 0 additions & 1 deletion go/api/string_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package api
//
// [valkey.io]: https://valkey.io/commands/#string
type StringCommands interface {

Set(key string, value string) (string, error)

SetWithOptions(key string, value string, options *SetOptions) (Result[string], error)
Expand Down

0 comments on commit a5eda6f

Please sign in to comment.