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