-
Notifications
You must be signed in to change notification settings - Fork 47
/
constants.go
113 lines (100 loc) · 4.15 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package rjs
import "fmt"
// Generic and Constant Errors to be returned to client to maintain stability
var (
ErrInternal = fmt.Errorf("error: internal client error")
ErrNoClientSet = fmt.Errorf("no redis client is set")
ErrTooManyOptionals = fmt.Errorf("error: too many optional arguments")
ErrNeedAtleastOneArg = fmt.Errorf("error: need atleast one argument in varing field")
// GoRedis specific Nil error
ErrGoRedisNil = fmt.Errorf("redis: nil")
)
const (
// ClientInactive signifies that the client is inactive in Handler
ClientInactive = "inactive"
// PopArrLast gives index of the last element for JSONArrPop
PopArrLast = -1
// DebugMemorySubcommand provide the corresponding MEMORY sub commands for JSONDebug
DebugMemorySubcommand DebugSubCommand = "MEMORY"
// DebugHelpSubcommand provide the corresponding HELP sub commands for JSONDebug
DebugHelpSubcommand DebugSubCommand = "HELP"
// DebugHelpOutput is the output of command JSON.Debug HELP <obj> [path]
DebugHelpOutput = "MEMORY <key> [path] - reports memory usage\nHELP - this message"
// ReJSON Commands
ReJSONCommandSET ReJSONCommandID = 0
ReJSONCommandGET ReJSONCommandID = 1
ReJSONCommandDEL ReJSONCommandID = 2
ReJSONCommandMGET ReJSONCommandID = 3
ReJSONCommandTYPE ReJSONCommandID = 4
ReJSONCommandNUMINCRBY ReJSONCommandID = 5
ReJSONCommandNUMMULTBY ReJSONCommandID = 6
ReJSONCommandSTRAPPEND ReJSONCommandID = 7
ReJSONCommandSTRLEN ReJSONCommandID = 8
ReJSONCommandARRAPPEND ReJSONCommandID = 9
ReJSONCommandARRLEN ReJSONCommandID = 10
ReJSONCommandARRPOP ReJSONCommandID = 11
ReJSONCommandARRINDEX ReJSONCommandID = 12
ReJSONCommandARRTRIM ReJSONCommandID = 13
ReJSONCommandARRINSERT ReJSONCommandID = 14
ReJSONCommandOBJKEYS ReJSONCommandID = 15
ReJSONCommandOBJLEN ReJSONCommandID = 16
ReJSONCommandDEBUG ReJSONCommandID = 17
ReJSONCommandFORGET ReJSONCommandID = 18
ReJSONCommandRESP ReJSONCommandID = 19
// JSONSET command Options
SetOptionNX SetOption = "NX"
SetOptionXX SetOption = "XX"
)
// JSONGet Command Options
var (
GETOptionSPACE = GetOption{"SPACE", " "}
GETOptionINDENT = GetOption{"INDENT", "\t"}
GETOptionNEWLINE = GetOption{"NEWLINE", "\n"}
GETOptionNOESCAPE = GetOption{"NOESCAPE", ""}
)
// commandName maps command id to the command name
var commandName = map[ReJSONCommandID]string{
ReJSONCommandSET: "JSON.SET",
ReJSONCommandGET: "JSON.GET",
ReJSONCommandDEL: "JSON.DEL",
ReJSONCommandMGET: "JSON.MGET",
ReJSONCommandTYPE: "JSON.TYPE",
ReJSONCommandNUMINCRBY: "JSON.NUMINCRBY",
ReJSONCommandNUMMULTBY: "JSON.NUMMULTBY",
ReJSONCommandSTRAPPEND: "JSON.STRAPPEND",
ReJSONCommandSTRLEN: "JSON.STRLEN",
ReJSONCommandARRAPPEND: "JSON.ARRAPPEND",
ReJSONCommandARRLEN: "JSON.ARRLEN",
ReJSONCommandARRPOP: "JSON.ARRPOP",
ReJSONCommandARRINDEX: "JSON.ARRINDEX",
ReJSONCommandARRTRIM: "JSON.ARRTRIM",
ReJSONCommandARRINSERT: "JSON.ARRINSERT",
ReJSONCommandOBJKEYS: "JSON.OBJKEYS",
ReJSONCommandOBJLEN: "JSON.OBJLEN",
ReJSONCommandDEBUG: "JSON.DEBUG",
ReJSONCommandFORGET: "JSON.FORGET",
ReJSONCommandRESP: "JSON.RESP",
}
// commandMux maps command id to their Command Builder functions
var commandMux = map[ReJSONCommandID]CommandBuilderFunc{
ReJSONCommandSET: commandJSONSet,
ReJSONCommandGET: commandJSONGet,
ReJSONCommandDEL: commandJSONGeneric,
ReJSONCommandMGET: commandJSONMGet,
ReJSONCommandTYPE: commandJSONGeneric,
ReJSONCommandNUMINCRBY: commandJSONNumIncrBy,
ReJSONCommandNUMMULTBY: commandJSONNumMultBy,
ReJSONCommandSTRAPPEND: commandJSONStrAppend,
ReJSONCommandSTRLEN: commandJSONGeneric,
ReJSONCommandARRAPPEND: commandJSONArrAppend,
ReJSONCommandARRLEN: commandJSONGeneric,
ReJSONCommandARRPOP: commandJSONArrPop,
ReJSONCommandARRINDEX: commandJSONArrIndex,
ReJSONCommandARRTRIM: commandJSONArrTrim,
ReJSONCommandARRINSERT: commandJSONArrInsert,
ReJSONCommandOBJKEYS: commandJSONGeneric,
ReJSONCommandOBJLEN: commandJSONGeneric,
ReJSONCommandDEBUG: commandJSONDebug,
ReJSONCommandFORGET: commandJSONGeneric,
ReJSONCommandRESP: commandJSONGeneric,
}