Skip to content

Commit

Permalink
Add Very Big Enum with all commands to protobuf.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
  • Loading branch information
Yury-Fridlyand committed Apr 15, 2024
1 parent dc94182 commit 6226836
Show file tree
Hide file tree
Showing 19 changed files with 2,168 additions and 1,334 deletions.
619 changes: 520 additions & 99 deletions csharp/lib/AsyncClient.cs

Large diffs are not rendered by default.

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,
}

Expand Down Expand Up @@ -96,7 +96,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 @@ -114,7 +114,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 @@ -232,7 +232,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 @@ -307,7 +307,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 @@ -319,7 +319,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 @@ -418,7 +418,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 @@ -429,7 +429,7 @@ mod tests {

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

Expand All @@ -446,7 +446,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
Loading

0 comments on commit 6226836

Please sign in to comment.