Skip to content

Commit

Permalink
Proto: Rename in RequestType enum according to Feng-Shui. (valkey-i…
Browse files Browse the repository at this point in the history
…o#1387)

* Rename in `RequestType` enum according to Feng-Shui. (#262)

Signed-off-by: Yury-Fridlyand <[email protected]>
Co-authored-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
2 people authored and cyip10 committed Jun 24, 2024
1 parent fa009cc commit f619f76
Show file tree
Hide file tree
Showing 23 changed files with 699 additions and 721 deletions.
48 changes: 24 additions & 24 deletions csharp/lib/AsyncClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public AsyncClient(string host, uint port, bool useTLS)
IntPtr[] args = _arrayPool.Rent(2);
args[0] = Marshal.StringToHGlobalAnsi(key);
args[1] = Marshal.StringToHGlobalAnsi(value);
string? result = await Command(args, 2, RequestType.SetString);
string? result = await Command(args, 2, RequestType.Set);
_arrayPool.Return(args);
return result;
}
Expand All @@ -47,7 +47,7 @@ public AsyncClient(string host, uint port, bool useTLS)
{
IntPtr[] args = _arrayPool.Rent(1);
args[0] = Marshal.StringToHGlobalAnsi(key);
string? result = await Command(args, 1, RequestType.GetString);
string? result = await Command(args, 1, RequestType.Get);
_arrayPool.Return(args);
return result;
}
Expand Down Expand Up @@ -129,8 +129,8 @@ private enum RequestType
{
InvalidRequest = 0,
CustomCommand = 1,
GetString = 2,
SetString = 3,
Get = 2,
Set = 3,
Ping = 4,
Info = 5,
Del = 6,
Expand All @@ -154,22 +154,22 @@ private enum RequestType
ClientUnblock = 24,
ClientUnpause = 25,
Expire = 26,
HashSet = 27,
HashGet = 28,
HashDel = 29,
HashExists = 30,
HSet = 27,
HGet = 28,
HDel = 29,
HExists = 30,
MGet = 31,
MSet = 32,
Incr = 33,
IncrBy = 34,
Decr = 35,
IncrByFloat = 36,
DecrBy = 37,
HashGetAll = 38,
HashMSet = 39,
HashMGet = 40,
HashIncrBy = 41,
HashIncrByFloat = 42,
HGetAll = 38,
HMSet = 39,
HMGet = 40,
HIncrBy = 41,
HIncrByFloat = 42,
LPush = 43,
LPop = 44,
RPush = 45,
Expand All @@ -188,19 +188,19 @@ private enum RequestType
Exists = 58,
Unlink = 59,
TTL = 60,
Zadd = 61,
Zrem = 62,
Zrange = 63,
Zcard = 64,
Zcount = 65,
ZAdd = 61,
ZRem = 62,
ZRange = 63,
ZCard = 64,
ZCount = 65,
ZIncrBy = 66,
ZScore = 67,
Type = 68,
HLen = 69,
Echo = 70,
ZPopMin = 71,
Strlen = 72,
Lindex = 73,
LIndex = 73,
ZPopMax = 74,
XRead = 75,
XAdd = 76,
Expand All @@ -211,21 +211,21 @@ private enum RequestType
XGroupDestroy = 81,
HSetNX = 82,
SIsMember = 83,
Hvals = 84,
HVals = 84,
PTTL = 85,
ZRemRangeByRank = 86,
Persist = 87,
ZRemRangeByScore = 88,
Time = 89,
Zrank = 90,
ZRank = 90,
Rename = 91,
DBSize = 92,
Brpop = 93,
Hkeys = 94,
BRPop = 93,
HKeys = 94,
PfAdd = 96,
PfCount = 97,
PfMerge = 98,
Blpop = 100,
BLPop = 100,
RPushX = 102,
LPushX = 103,
}
Expand Down
18 changes: 9 additions & 9 deletions glide-core/src/client/value_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) enum ExpectedReturnType {
BulkString,
Set,
DoubleOrNull,
ZrankReturnType,
ZRankReturnType,
JsonToggleReturnType,
ArrayOfBools,
ArrayOfDoubleOrNull,
Expand Down Expand Up @@ -101,7 +101,7 @@ pub(crate) fn convert_to_expected_type(
Value::Nil => Ok(value),
_ => Ok(Value::Double(from_owned_redis_value::<f64>(value)?)),
},
ExpectedReturnType::ZrankReturnType => match value {
ExpectedReturnType::ZRankReturnType => match value {
Value::Nil => Ok(value),
Value::Array(mut array) => {
if array.len() != 2 {
Expand All @@ -119,7 +119,7 @@ pub(crate) fn convert_to_expected_type(
}
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to Array (ZrankResponseType)",
"Response couldn't be converted to Array (ZRankResponseType)",
format!("(response was {:?})", value),
)
.into()),
Expand Down Expand Up @@ -419,7 +419,7 @@ pub(crate) fn expected_type_for_cmd(cmd: &Cmd) -> Option<ExpectedReturnType> {
.map(|_| ExpectedReturnType::MapOfStringToDouble),
b"ZRANK" | b"ZREVRANK" => cmd
.position(b"WITHSCORE")
.map(|_| ExpectedReturnType::ZrankReturnType),
.map(|_| ExpectedReturnType::ZRankReturnType),
b"SPOP" => {
if cmd.arg_idx(2).is_some() {
Some(ExpectedReturnType::Set)
Expand Down Expand Up @@ -751,7 +751,7 @@ mod tests {
.arg("member")
.arg("withscore")
),
Some(ExpectedReturnType::ZrankReturnType)
Some(ExpectedReturnType::ZRankReturnType)
));

assert!(expected_type_for_cmd(redis::cmd("zrank").arg("key").arg("member")).is_none());
Expand All @@ -763,7 +763,7 @@ mod tests {
.arg("member")
.arg("withscore")
),
Some(ExpectedReturnType::ZrankReturnType)
Some(ExpectedReturnType::ZRankReturnType)
));

assert!(expected_type_for_cmd(redis::cmd("ZREVRANK").arg("key").arg("member")).is_none());
Expand Down Expand Up @@ -899,7 +899,7 @@ mod tests {
#[test]
fn test_convert_to_zrank_return_type() {
assert_eq!(
convert_to_expected_type(Value::Nil, Some(ExpectedReturnType::ZrankReturnType)),
convert_to_expected_type(Value::Nil, Some(ExpectedReturnType::ZRankReturnType)),
Ok(Value::Nil)
);

Expand All @@ -910,7 +910,7 @@ mod tests {

let array_result = convert_to_expected_type(
Value::Array(array),
Some(ExpectedReturnType::ZrankReturnType),
Some(ExpectedReturnType::ZRankReturnType),
)
.unwrap();

Expand All @@ -927,7 +927,7 @@ mod tests {
let array_err = vec![Value::BulkString(b"key".to_vec())];
assert!(convert_to_expected_type(
Value::Array(array_err),
Some(ExpectedReturnType::ZrankReturnType)
Some(ExpectedReturnType::ZRankReturnType)
)
.is_err());
}
Expand Down
56 changes: 27 additions & 29 deletions glide-core/src/protobuf/redis_request.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ enum RequestType {
InvalidRequest = 0;
/// An unknown command, where all arguments are defined by the user.
CustomCommand = 1;
/// Type of a get string request.
GetString = 2;
/// Type of a set string request.
SetString = 3;
Get = 2;
Set = 3;
Ping = 4;
Info = 5;
Del = 6;
Expand All @@ -68,22 +66,22 @@ enum RequestType {
ClientUnblock = 24;
ClientUnpause = 25;
Expire = 26;
HashSet = 27;
HashGet = 28;
HashDel = 29;
HashExists = 30;
HSet = 27;
HGet = 28;
HDel = 29;
HExists = 30;
MGet=31;
MSet=32;
Incr=33;
IncrBy=34;
Decr=35;
IncrByFloat=36;
DecrBy=37;
HashGetAll=38;
HashMSet=39;
HashMGet=40;
HashIncrBy = 41;
HashIncrByFloat = 42;
HGetAll=38;
HMSet=39;
HMGet=40;
HIncrBy = 41;
HIncrByFloat = 42;
LPush = 43;
LPop = 44;
RPush = 45;
Expand All @@ -102,19 +100,19 @@ enum RequestType {
Exists = 58;
Unlink = 59;
TTL = 60;
Zadd = 61;
Zrem = 62;
Zrange = 63;
Zcard = 64;
Zcount = 65;
ZAdd = 61;
ZRem = 62;
ZRange = 63;
ZCard = 64;
ZCount = 65;
ZIncrBy = 66;
ZScore = 67;
Type = 68;
HLen = 69;
Echo = 70;
ZPopMin = 71;
Strlen = 72;
Lindex = 73;
LIndex = 73;
ZPopMax = 74;
XRead = 75;
XAdd = 76;
Expand All @@ -125,22 +123,22 @@ enum RequestType {
XGroupDestroy = 81;
HSetNX = 82;
SIsMember = 83;
Hvals = 84;
HVals = 84;
PTTL = 85;
ZRemRangeByRank = 86;
Persist = 87;
ZRemRangeByScore = 88;
Time = 89;
Zrank = 90;
ZRank = 90;
Rename = 91;
DBSize = 92;
Brpop = 93;
Hkeys = 94;
Spop = 95;
BRPop = 93;
HKeys = 94;
SPop = 95;
PfAdd = 96;
PfCount = 97;
PfMerge = 98;
Blpop = 100;
BLPop = 100;
LInsert = 101;
RPushX = 102;
LPushX = 103;
Expand All @@ -165,14 +163,14 @@ enum RequestType {
GeoHash = 122;
ObjectEncoding = 123;
SDiff = 124;
ObjectIdletime = 125;
ObjectRefcount = 126;
LOLWUT = 100500;
ObjectIdleTime = 125;
ObjectRefCount = 126;
Lolwut = 100500;
GeoDist = 127;
GeoPos = 128;
BZPopMax = 129;
ObjectFreq = 130;
RenameNx = 131;
RenameNX = 131;
Touch = 132;
ZRevRank = 133;
ZInterStore = 134;
Expand Down
Loading

0 comments on commit f619f76

Please sign in to comment.