mirror of
https://github.com/joyieldInc/predixy.git
synced 2025-12-24 22:46:41 +08:00
Change config description style
This commit is contained in:
parent
95f4580ccf
commit
dcdc9a1ba0
@ -1,83 +1,95 @@
|
|||||||
# CustomCommand section must be defined before Latency monitor to support all commands
|
## Custom Command
|
||||||
#
|
## CustomCommand {
|
||||||
# NOTE: only support maximum 16 custom commands
|
## command { #command string, must be lowercase
|
||||||
#
|
## [Mode read|write|admin[|[keyAt2|keyAt3]] #default write, default key position is 1
|
||||||
# [...] must be specify
|
## [MinArgs [2-]] #default 2, including command itself
|
||||||
# (...) optional. it has default value
|
## [MaxArgs [2-]] #default 2, must be MaxArgs >= MinArgs
|
||||||
#
|
## }...
|
||||||
# CustomCommand [alias1] { ## module alias. just a delimter
|
## }
|
||||||
# [command1] { ## command string, must be lower case. i.e. setnx, expire, ...
|
|
||||||
# (minArgs) (val) ## minimum arguments(including command itself). default is 2(key only)
|
|
||||||
# (maxArgs) (val) ## maximum arguments(including command itself). default is 2(key only)
|
|
||||||
# (mode) (val) ## a command mode Read/Write/Admin is exclusive. default is Write.
|
|
||||||
# }
|
|
||||||
# [command2] {
|
|
||||||
# ...
|
|
||||||
# }
|
|
||||||
# ...
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# default key position is first parameter. i.e. command1 key ...
|
|
||||||
# if you want to use other position, add KeyAt2(key is second) or KeyAt3(key is third) to mode with '|'
|
|
||||||
# i.e. mode Write|KeyAt2
|
|
||||||
#
|
|
||||||
# in case of 'mode KeyAt2', it will resolved as Write|KeyAt2
|
|
||||||
|
|
||||||
# from redis source src/modules/hello.c
|
## This section must be defined before Latency monitor to support all commands
|
||||||
CustomCommand hello {
|
## Currently support maximum 16 custom commands
|
||||||
# hello.push.native key value
|
|
||||||
hello.push.native {
|
## Example:
|
||||||
minArgs 3
|
#CustomCommand {
|
||||||
maxArgs 3
|
##------------------------------------------------------------------------
|
||||||
mode Write
|
# custom.ttl {
|
||||||
}
|
# Mode keyAt2
|
||||||
# hello.repl2 <list-key>
|
# MinArgs 3
|
||||||
# just skipped since minArgs = 2, maxArgs = 2, mode = Write are default values
|
# MaxArgs 3
|
||||||
hello.repl2 {
|
# }
|
||||||
}
|
#### custom.ttl miliseconds key
|
||||||
# hello.toggle.case key
|
#### Mode = write|keyAt2, MinArgs/MaxArgs = 3 = command + miliseconds + key
|
||||||
# same as hello.repl2
|
##------------------------------------------------------------------------
|
||||||
hello.toggle.case {
|
## from redis source src/modules/hello.c
|
||||||
}
|
# hello.push.native {
|
||||||
# hello.more.expire key milliseconds
|
# MinArgs 3
|
||||||
hello.more.expire {
|
# MaxArgs 3
|
||||||
minArgs 3
|
# }
|
||||||
maxArgs 3
|
#### hello.push.native key value
|
||||||
}
|
#### Mode = write, MinArgs/MaxArgs = 3 = command) + key + value
|
||||||
# hello.zsumrange key startscore endscore
|
##------------------------------------------------------------------------
|
||||||
hello.zsumrange {
|
# hello.repl2 {
|
||||||
minArgs 4
|
# }
|
||||||
maxArgs 4
|
#### hello.repl2 <list-key>
|
||||||
mode Read
|
#### Mode = write, MinArgs/MaxArgs = 2 = command + list-key
|
||||||
}
|
##------------------------------------------------------------------------
|
||||||
# hello.lexrange key min_lex max_lex min_age max_age
|
# hello.toggle.case {
|
||||||
hello.lexrange {
|
# }
|
||||||
minArgs 6
|
#### hello.toggle.case key
|
||||||
maxArgs 6
|
#### Mode = write, MinArgs/MaxArgs = 2 = command + key
|
||||||
mode Read
|
##------------------------------------------------------------------------
|
||||||
}
|
# hello.more.expire {
|
||||||
# hello.hcopy key srcfield dstfield
|
# MinArgs 3
|
||||||
hello.hcopy {
|
# MaxArgs 3
|
||||||
minArgs 4
|
# }
|
||||||
maxArgs 4
|
#### hello.more.expire key milliseconds
|
||||||
}
|
#### Mode = write, MinArgs/MaxArgs = 3 = command + key + milliseconds
|
||||||
}
|
##------------------------------------------------------------------------
|
||||||
|
# hello.zsumrange {
|
||||||
|
# MinArgs 4
|
||||||
|
# MaxArgs 4
|
||||||
|
# Mode read
|
||||||
|
# }
|
||||||
|
#### hello.zsumrange key startscore endscore
|
||||||
|
#### Mode = read, MinArgs/MaxArgs = 4 = command + key + startscore + endscore
|
||||||
|
##------------------------------------------------------------------------
|
||||||
|
# hello.lexrange {
|
||||||
|
# MinArgs 6
|
||||||
|
# MaxArgs 6
|
||||||
|
# Mode read
|
||||||
|
# }
|
||||||
|
#### hello.lexrange key min_lex max_lex min_age max_age
|
||||||
|
#### Mode = read, MinArgs/MaxArgs = 6 = command + key + min_lex + max_lex + min_age + max_age
|
||||||
|
##------------------------------------------------------------------------
|
||||||
|
# hello.hcopy {
|
||||||
|
# MinArgs 4
|
||||||
|
# MaxArgs 4
|
||||||
|
# }
|
||||||
|
#### hello.hcopy key srcfield dstfield
|
||||||
|
#### Mode = write, MinArgs/MaxArgs = 4 = command + key + srcfield) + dstfield
|
||||||
|
##------------------------------------------------------------------------
|
||||||
|
## from redis source src/modules/hellotype.c
|
||||||
|
# hellotype.insert {
|
||||||
|
# MinArgs 3
|
||||||
|
# MaxArgs 3
|
||||||
|
# }
|
||||||
|
#### hellotype.insert key value
|
||||||
|
#### Mode = write, MinArgs/MaxArgs = 3 = command + key + value
|
||||||
|
##------------------------------------------------------------------------
|
||||||
|
# hellotype.range {
|
||||||
|
# MinArgs 4
|
||||||
|
# MaxArgs 4
|
||||||
|
# Mode read
|
||||||
|
# }
|
||||||
|
#### hellotype.range key first count
|
||||||
|
#### Mode = read, MinArgs/MaxArgs = 4 = command + key + first + count
|
||||||
|
##------------------------------------------------------------------------
|
||||||
|
# hellotype.len {
|
||||||
|
# Mode read
|
||||||
|
# }
|
||||||
|
#### hellotype.len key
|
||||||
|
#### Mode = read, MinArgs/MaxArgs = 2 = command + key
|
||||||
|
##------------------------------------------------------------------------
|
||||||
|
#}
|
||||||
|
|
||||||
# from redis source src/modules/hellotype.c
|
|
||||||
CustomCommand hellotype {
|
|
||||||
# hellotype.insert key value
|
|
||||||
hellotype.insert {
|
|
||||||
minArgs 3
|
|
||||||
maxArgs 3
|
|
||||||
}
|
|
||||||
# hellotype.range key first count
|
|
||||||
hellotype.range {
|
|
||||||
minArgs 4
|
|
||||||
maxArgs 4
|
|
||||||
mode Read
|
|
||||||
}
|
|
||||||
# hellotype.len key
|
|
||||||
hello.len {
|
|
||||||
mode Read
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
19
src/Conf.cpp
19
src/Conf.cpp
@ -381,13 +381,16 @@ void Conf::setCustomCommand(const ConfParser::Node* node)
|
|||||||
CustomCommandConf::init(cc, p->key.c_str(), Command::Sentinel);
|
CustomCommandConf::init(cc, p->key.c_str(), Command::Sentinel);
|
||||||
auto s = p->sub;
|
auto s = p->sub;
|
||||||
for (;s ; s = s->next) {
|
for (;s ; s = s->next) {
|
||||||
if (setInt(cc.cmd.minArgs, "minArgs", s, 2)) {
|
if (setInt(cc.cmd.minArgs, "MinArgs", s, 2)) {
|
||||||
} else if (setInt(cc.cmd.maxArgs, "maxArgs", s, 2, 9999)) {
|
} else if (setInt(cc.cmd.maxArgs, "MaxArgs", s, 2, 9999)) {
|
||||||
} else if (setCommandMode(cc.cmd.mode, "mode", s)) {
|
} else if (setCommandMode(cc.cmd.mode, "Mode", s)) {
|
||||||
} else {
|
} else {
|
||||||
Throw(UnknownKey, "%s:%d unknown key %s", s->file, s->line, s->key.c_str());
|
Throw(UnknownKey, "%s:%d unknown key %s", s->file, s->line, s->key.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (cc.cmd.maxArgs < cc.cmd.minArgs) {
|
||||||
|
Throw(InvalidValue, "%s:%d must be MaxArgs >= MinArgs", p->file, p->line);
|
||||||
|
}
|
||||||
Command::addCustomCommand(&cc.cmd);
|
Command::addCustomCommand(&cc.cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,15 +408,15 @@ bool Conf::setCommandMode(int& mode, const char* name, const ConfParser::Node* n
|
|||||||
std::string mask;
|
std::string mask;
|
||||||
std::istringstream is(n->val);
|
std::istringstream is(n->val);
|
||||||
while (std::getline(is, mask, '|')) {
|
while (std::getline(is, mask, '|')) {
|
||||||
if ((strcasecmp(mask.c_str(), "Write") == 0)) {
|
if ((strcasecmp(mask.c_str(), "write") == 0)) {
|
||||||
mode |= Command::Write;
|
mode |= Command::Write;
|
||||||
} else if ((strcasecmp(mask.c_str(), "Read") == 0)) {
|
} else if ((strcasecmp(mask.c_str(), "read") == 0)) {
|
||||||
mode |= Command::Read;
|
mode |= Command::Read;
|
||||||
} else if ((strcasecmp(mask.c_str(), "Admin") == 0)) {
|
} else if ((strcasecmp(mask.c_str(), "admin") == 0)) {
|
||||||
mode |= Command::Admin;
|
mode |= Command::Admin;
|
||||||
} else if ((strcasecmp(mask.c_str(), "KeyAt2") == 0)) {
|
} else if ((strcasecmp(mask.c_str(), "keyAt2") == 0)) {
|
||||||
mode |= Command::KeyAt2;
|
mode |= Command::KeyAt2;
|
||||||
} else if ((strcasecmp(mask.c_str(), "KeyAt3") == 0)) {
|
} else if ((strcasecmp(mask.c_str(), "keyAt3") == 0)) {
|
||||||
mode |= Command::KeyAt3;
|
mode |= Command::KeyAt3;
|
||||||
} else {
|
} else {
|
||||||
Throw(InvalidValue, "%s:%d unknown mode %s", n->file, n->line, mask.c_str());
|
Throw(InvalidValue, "%s:%d unknown mode %s", n->file, n->line, mask.c_str());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user