mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-04 15:42:40 +08:00
Renamed *AccessKey type to better represent the response on *KeyExtractionFunc types
This commit is contained in:
@@ -147,12 +147,12 @@ func (server *EchoVault) AddCommand(command CommandOptions) error {
|
||||
}(),
|
||||
Description: command.Description,
|
||||
Sync: command.Sync,
|
||||
KeyExtractionFunc: internal.KeyExtractionFunc(func(cmd []string) (internal.AccessKeys, error) {
|
||||
KeyExtractionFunc: internal.KeyExtractionFunc(func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
accessKeys, err := command.KeyExtractionFunc(cmd)
|
||||
if err != nil {
|
||||
return internal.AccessKeys{}, err
|
||||
return internal.KeyExtractionFuncResult{}, err
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: []string{},
|
||||
ReadKeys: accessKeys.ReadKeys,
|
||||
WriteKeys: accessKeys.WriteKeys,
|
||||
@@ -193,11 +193,13 @@ func (server *EchoVault) AddCommand(command CommandOptions) error {
|
||||
}
|
||||
return cats
|
||||
}(),
|
||||
Description: command.Description,
|
||||
Sync: command.Sync,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) { return internal.AccessKeys{}, nil },
|
||||
HandlerFunc: func(param internal.HandlerFuncParams) ([]byte, error) { return nil, nil },
|
||||
SubCommands: make([]internal.SubCommand, len(command.SubCommand)),
|
||||
Description: command.Description,
|
||||
Sync: command.Sync,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{}, nil
|
||||
},
|
||||
HandlerFunc: func(param internal.HandlerFuncParams) ([]byte, error) { return nil, nil },
|
||||
SubCommands: make([]internal.SubCommand, len(command.SubCommand)),
|
||||
}
|
||||
|
||||
for i, sc := range command.SubCommand {
|
||||
@@ -214,12 +216,12 @@ func (server *EchoVault) AddCommand(command CommandOptions) error {
|
||||
}(),
|
||||
Description: sc.Description,
|
||||
Sync: sc.Sync,
|
||||
KeyExtractionFunc: internal.KeyExtractionFunc(func(cmd []string) (internal.AccessKeys, error) {
|
||||
KeyExtractionFunc: internal.KeyExtractionFunc(func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
accessKeys, err := sc.KeyExtractionFunc(cmd)
|
||||
if err != nil {
|
||||
return internal.AccessKeys{}, err
|
||||
return internal.KeyExtractionFuncResult{}, err
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: []string{},
|
||||
ReadKeys: accessKeys.ReadKeys,
|
||||
WriteKeys: accessKeys.WriteKeys,
|
||||
|
@@ -495,8 +495,8 @@ func Commands() []internal.Command {
|
||||
Categories: []string{constants.ConnectionCategory, constants.SlowCategory},
|
||||
Description: "(AUTH [username] password) Authenticates the connection",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -510,8 +510,8 @@ func Commands() []internal.Command {
|
||||
Categories: []string{},
|
||||
Description: "Access-Control-List commands",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -525,8 +525,8 @@ func Commands() []internal.Command {
|
||||
Description: `(ACL CAT [category]) List all the categories.
|
||||
If the optional category is provided, list all the commands in the category`,
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -540,8 +540,8 @@ If the optional category is provided, list all the commands in the category`,
|
||||
Categories: []string{constants.AdminCategory, constants.SlowCategory, constants.DangerousCategory},
|
||||
Description: "(ACL USERS) List all usernames of the configured ACL users",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -555,8 +555,8 @@ If the optional category is provided, list all the commands in the category`,
|
||||
Categories: []string{constants.AdminCategory, constants.SlowCategory, constants.DangerousCategory},
|
||||
Description: "(ACL SETUSER) Configure a new or existing user",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -570,8 +570,8 @@ If the optional category is provided, list all the commands in the category`,
|
||||
Categories: []string{constants.AdminCategory, constants.SlowCategory, constants.DangerousCategory},
|
||||
Description: "(ACL GETUSER username) List the ACL rules of a user",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -585,8 +585,8 @@ If the optional category is provided, list all the commands in the category`,
|
||||
Categories: []string{constants.AdminCategory, constants.SlowCategory, constants.DangerousCategory},
|
||||
Description: "(ACL DELUSER username [username ...]) Deletes users and terminates their connections. Cannot delete default user",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -600,8 +600,8 @@ If the optional category is provided, list all the commands in the category`,
|
||||
Categories: []string{constants.FastCategory},
|
||||
Description: "(ACL WHOAMI) Returns the authenticated user of the current connection",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -615,8 +615,8 @@ If the optional category is provided, list all the commands in the category`,
|
||||
Categories: []string{constants.AdminCategory, constants.SlowCategory, constants.DangerousCategory},
|
||||
Description: "(ACL LIST) Dumps effective acl rules in acl config file format",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -633,8 +633,8 @@ If the optional category is provided, list all the commands in the category`,
|
||||
When 'MERGE' is passed, users from config file who share a username with users in memory will be merged.
|
||||
When 'REPLACE' is passed, users from config file who share a username with users in memory will replace the user in memory.`,
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -648,8 +648,8 @@ When 'REPLACE' is passed, users from config file who share a username with users
|
||||
Categories: []string{constants.AdminCategory, constants.SlowCategory, constants.DangerousCategory},
|
||||
Description: "(ACL SAVE) Saves the effective ACL rules the configured ACL config file",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
|
@@ -197,8 +197,8 @@ func Commands() []internal.Command {
|
||||
Categories: []string{constants.AdminCategory, constants.SlowCategory},
|
||||
Description: "Get a list of all the commands in available on the echovault with categories and descriptions",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -212,8 +212,8 @@ func Commands() []internal.Command {
|
||||
Categories: []string{},
|
||||
Description: "Commands pertaining to echovault commands",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -226,8 +226,8 @@ func Commands() []internal.Command {
|
||||
Categories: []string{constants.SlowCategory, constants.ConnectionCategory},
|
||||
Description: "Get command documentation",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -241,8 +241,8 @@ func Commands() []internal.Command {
|
||||
Categories: []string{constants.SlowCategory},
|
||||
Description: "Get the dumber of commands in the echovault",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -257,8 +257,8 @@ func Commands() []internal.Command {
|
||||
Description: `(COMMAND LIST [FILTERBY <ACLCAT category | PATTERN pattern | MODULE module>]) Get the list of command names.
|
||||
Allows for filtering by ACL category or glob pattern.`,
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -274,8 +274,8 @@ Allows for filtering by ACL category or glob pattern.`,
|
||||
Categories: []string{constants.AdminCategory, constants.SlowCategory, constants.DangerousCategory},
|
||||
Description: "(SAVE) Trigger a snapshot save",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -294,8 +294,8 @@ Allows for filtering by ACL category or glob pattern.`,
|
||||
Categories: []string{constants.AdminCategory, constants.FastCategory, constants.DangerousCategory},
|
||||
Description: "(LASTSAVE) Get unix timestamp for the latest snapshot in milliseconds.",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -315,8 +315,8 @@ Allows for filtering by ACL category or glob pattern.`,
|
||||
Categories: []string{constants.AdminCategory, constants.SlowCategory, constants.DangerousCategory},
|
||||
Description: "(REWRITEAOF) Trigger re-writing of append process",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
|
@@ -40,8 +40,8 @@ func Commands() []internal.Command {
|
||||
Categories: []string{constants.FastCategory, constants.ConnectionCategory},
|
||||
Description: "(PING [value]) Ping the echovault. If a value is provided, the value will be echoed.",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
|
@@ -20,20 +20,20 @@ import (
|
||||
"github.com/echovault/echovault/internal"
|
||||
)
|
||||
|
||||
func setKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func setKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 || len(cmd) > 7 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func msetKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func msetKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd[1:])%2 != 0 {
|
||||
return internal.AccessKeys{}, errors.New("each key must be paired with a value")
|
||||
return internal.KeyExtractionFuncResult{}, errors.New("each key must be paired with a value")
|
||||
}
|
||||
var keys []string
|
||||
for i, key := range cmd[1:] {
|
||||
@@ -41,95 +41,95 @@ func msetKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: keys,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func getKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func mgetKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func mgetKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func delKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func delKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func persistKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func persistKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func expireTimeKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func expireTimeKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ttlKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func ttlKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func expireKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func expireKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 || len(cmd) > 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func expireAtKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func expireAtKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 || len(cmd) > 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
|
@@ -20,139 +20,139 @@ import (
|
||||
"github.com/echovault/echovault/internal"
|
||||
)
|
||||
|
||||
func hsetKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hsetKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hsetnxKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hsetnxKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hgetKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hgetKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hstrlenKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hstrlenKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hvalsKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hvalsKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hrandfieldKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hrandfieldKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 || len(cmd) > 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
if len(cmd) == 2 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hlenKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hlenKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hkeysKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hkeysKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hincrbyKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hincrbyKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hgetallKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hgetallKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hexistsKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hexistsKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func hdelKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func hdelKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
|
@@ -20,110 +20,110 @@ import (
|
||||
"github.com/echovault/echovault/internal"
|
||||
)
|
||||
|
||||
func lpushKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func lpushKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func popKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func popKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func llenKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func llenKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func lrangeKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func lrangeKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func lindexKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func lindexKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func lsetKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func lsetKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ltrimKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func ltrimKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func lremKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func lremKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func rpushKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func rpushKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func lmoveKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func lmoveKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 5 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:3],
|
||||
|
@@ -108,12 +108,12 @@ func Commands() []internal.Command {
|
||||
Categories: []string{constants.PubSubCategory, constants.ConnectionCategory, constants.SlowCategory},
|
||||
Description: "(SUBSCRIBE channel [channel ...]) Subscribe to one or more channels.",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
// Treat the channels as keys
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: cmd[1:],
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -127,12 +127,12 @@ func Commands() []internal.Command {
|
||||
Categories: []string{constants.PubSubCategory, constants.ConnectionCategory, constants.SlowCategory},
|
||||
Description: "(PSUBSCRIBE pattern [pattern ...]) Subscribe to one or more glob patterns.",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
// Treat the patterns as keys
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: cmd[1:],
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -146,12 +146,12 @@ func Commands() []internal.Command {
|
||||
Categories: []string{constants.PubSubCategory, constants.FastCategory},
|
||||
Description: "(PUBLISH channel message) Publish a message to the specified channel.",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
// Treat the channel as a key
|
||||
if len(cmd) != 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: cmd[1:2],
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -167,9 +167,9 @@ func Commands() []internal.Command {
|
||||
If the channel list is not provided, then the connection will be unsubscribed from all the channels that
|
||||
it's currently subscribe to.`,
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
// Treat the channels as keys
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: cmd[1:],
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -185,8 +185,8 @@ it's currently subscribe to.`,
|
||||
If the pattern list is not provided, then the connection will be unsubscribed from all the patterns that
|
||||
it's currently subscribe to.`,
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: cmd[1:],
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -200,8 +200,8 @@ it's currently subscribe to.`,
|
||||
Categories: []string{},
|
||||
Description: "",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -219,8 +219,8 @@ it's currently subscribe to.`,
|
||||
match the given pattern. If no pattern is provided, all active channels are returned. Active channels are
|
||||
channels with 1 or more subscribers.`,
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -234,8 +234,8 @@ channels with 1 or more subscribers.`,
|
||||
Categories: []string{constants.PubSubCategory, constants.SlowCategory},
|
||||
Description: `(PUBSUB NUMPAT) Return the number of patterns that are currently subscribed to by clients.`,
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
@@ -250,8 +250,8 @@ channels with 1 or more subscribers.`,
|
||||
Description: `(PUBSUB NUMSUB [channel [channel ...]]) Return an array of arrays containing the provided
|
||||
channel name and how many clients are currently subscribed to the channel.`,
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) (internal.AccessKeys, error) {
|
||||
return internal.AccessKeys{
|
||||
KeyExtractionFunc: func(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: cmd[2:],
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: make([]string, 0),
|
||||
|
@@ -22,64 +22,64 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func saddKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func saddKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func scardKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func scardKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func sdiffKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func sdiffKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func sdiffstoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func sdiffstoreKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[2:],
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func sinterKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func sinterKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func sintercardKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func sintercardKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
|
||||
limitIdx := slices.IndexFunc(cmd, func(s string) bool {
|
||||
@@ -87,124 +87,124 @@ func sintercardKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
})
|
||||
|
||||
if limitIdx == -1 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:limitIdx],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func sinterstoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func sinterstoreKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[2:],
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func sismemberKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func sismemberKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func smembersKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func smembersKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func smismemberKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func smismemberKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func smoveKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func smoveKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:3],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func spopKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func spopKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 || len(cmd) > 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func srandmemberKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func srandmemberKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 || len(cmd) > 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func sremKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func sremKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func sunionKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func sunionKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func sunionstoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func sunionstoreKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[2:],
|
||||
WriteKeys: cmd[1:2],
|
||||
|
@@ -22,42 +22,42 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func zaddKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zaddKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zcardKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zcardKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zcountKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zcountKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zdiffKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zdiffKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
|
||||
withscoresIndex := slices.IndexFunc(cmd, func(s string) bool {
|
||||
@@ -65,45 +65,45 @@ func zdiffKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
})
|
||||
|
||||
if withscoresIndex == -1 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:withscoresIndex],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zdiffstoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zdiffstoreKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[2:],
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zincrbyKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zincrbyKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zinterKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zinterKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
endIdx := slices.IndexFunc(cmd[1:], func(s string) bool {
|
||||
if strings.EqualFold(s, "WEIGHTS") ||
|
||||
@@ -114,25 +114,25 @@ func zinterKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
return false
|
||||
})
|
||||
if endIdx == -1 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
if endIdx >= 1 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:endIdx],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
|
||||
func zinterstoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zinterstoreKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
endIdx := slices.IndexFunc(cmd[1:], func(s string) bool {
|
||||
if strings.EqualFold(s, "WEIGHTS") ||
|
||||
@@ -143,192 +143,192 @@ func zinterstoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
return false
|
||||
})
|
||||
if endIdx == -1 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[2:],
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
if endIdx >= 3 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[2:endIdx],
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
|
||||
func zmpopKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zmpopKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
endIdx := slices.IndexFunc(cmd, func(s string) bool {
|
||||
return slices.Contains([]string{"MIN", "MAX", "COUNT"}, strings.ToUpper(s))
|
||||
})
|
||||
if endIdx == -1 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:],
|
||||
}, nil
|
||||
}
|
||||
if endIdx >= 2 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:endIdx],
|
||||
}, nil
|
||||
}
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
|
||||
func zmscoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zmscoreKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zpopKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zpopKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 || len(cmd) > 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zrandmemberKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zrandmemberKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 || len(cmd) > 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zrankKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zrankKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 || len(cmd) > 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zremKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zremKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zrevrankKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zrevrankKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zscoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zscoreKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zremrangebylexKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zremrangebylexKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zremrangebyrankKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zremrangebyrankKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zremrangebyscoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zremrangebyscoreKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zlexcountKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zlexcountKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zrangeKeyCount(cmd []string) (internal.AccessKeys, error) {
|
||||
func zrangeKeyCount(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 4 || len(cmd) > 10 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zrangeStoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zrangeStoreKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 5 || len(cmd) > 11 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[2:3],
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func zunionKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zunionKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
endIdx := slices.IndexFunc(cmd[1:], func(s string) bool {
|
||||
if strings.EqualFold(s, "WEIGHTS") ||
|
||||
@@ -339,25 +339,25 @@ func zunionKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
return false
|
||||
})
|
||||
if endIdx == -1 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
if endIdx >= 1 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:endIdx],
|
||||
WriteKeys: cmd[1:endIdx],
|
||||
}, nil
|
||||
}
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
|
||||
func zunionstoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func zunionstoreKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) < 3 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
endIdx := slices.IndexFunc(cmd[1:], func(s string) bool {
|
||||
if strings.EqualFold(s, "WEIGHTS") ||
|
||||
@@ -368,18 +368,18 @@ func zunionstoreKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
return false
|
||||
})
|
||||
if endIdx == -1 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[2:],
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
if endIdx >= 1 {
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[2:endIdx],
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
|
@@ -20,33 +20,33 @@ import (
|
||||
"github.com/echovault/echovault/internal"
|
||||
)
|
||||
|
||||
func setRangeKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func setRangeKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: make([]string, 0),
|
||||
WriteKeys: cmd[1:2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
func strLenKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func strLenKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 2 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func subStrKeyFunc(cmd []string) (internal.AccessKeys, error) {
|
||||
func subStrKeyFunc(cmd []string) (internal.KeyExtractionFuncResult, error) {
|
||||
if len(cmd) != 4 {
|
||||
return internal.AccessKeys{}, errors.New(constants.WrongArgsResponse)
|
||||
return internal.KeyExtractionFuncResult{}, errors.New(constants.WrongArgsResponse)
|
||||
}
|
||||
return internal.AccessKeys{
|
||||
return internal.KeyExtractionFuncResult{
|
||||
Channels: make([]string, 0),
|
||||
ReadKeys: cmd[1:2],
|
||||
WriteKeys: make([]string, 0),
|
||||
|
@@ -47,13 +47,13 @@ type SnapshotObject struct {
|
||||
LatestSnapshotMilliseconds int64
|
||||
}
|
||||
|
||||
type AccessKeys struct {
|
||||
type KeyExtractionFuncResult struct {
|
||||
Channels []string
|
||||
ReadKeys []string
|
||||
WriteKeys []string
|
||||
}
|
||||
|
||||
type KeyExtractionFunc func(cmd []string) (AccessKeys, error)
|
||||
type KeyExtractionFunc func(cmd []string) (KeyExtractionFuncResult, error)
|
||||
|
||||
type HandlerFuncParams struct {
|
||||
Context context.Context
|
||||
|
@@ -35,11 +35,11 @@ type EchoVault interface {
|
||||
DeleteKey(ctx context.Context, key string) error
|
||||
}
|
||||
|
||||
type PluginAccessKeys struct {
|
||||
type PluginKeyExtractionFuncResult struct {
|
||||
ReadKeys []string
|
||||
WriteKeys []string
|
||||
}
|
||||
type PluginKeyExtractionFunc func(cmd []string) (PluginAccessKeys, error)
|
||||
type PluginKeyExtractionFunc func(cmd []string) (PluginKeyExtractionFuncResult, error)
|
||||
|
||||
type PluginHandlerFunc func(params PluginHandlerFuncParams) ([]byte, error)
|
||||
type PluginHandlerFuncParams struct {
|
||||
|
Reference in New Issue
Block a user