Skip to content

Commit c19881f

Browse files
chore: bump redis to v0.32.5
Signed-off-by: Kate Goldenring <[email protected]>
1 parent 4887765 commit c19881f

File tree

4 files changed

+94
-52
lines changed

4 files changed

+94
-52
lines changed

Cargo.lock

Lines changed: 29 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ lazy_static = "1.5"
144144
path-absolutize = "3"
145145
quote = "1"
146146
rand = "0.9"
147-
redis = "0.29"
147+
redis = "0.32.5"
148148
regex = "1"
149149
reqwest = { version = "0.12", features = ["stream", "blocking"] }
150150
rusqlite = "0.34"

crates/factor-outbound-redis/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = { workspace = true }
66

77
[dependencies]
88
anyhow = { workspace = true }
9-
redis = { version = "0.25", features = ["tokio-comp", "tokio-native-tls-comp", "aio"] }
9+
redis = { workspace = true , features = ["tokio-comp", "tokio-native-tls-comp", "aio"] }
1010
spin-core = { path = "../core" }
1111
spin-factor-outbound-networking = { path = "../factor-outbound-networking" }
1212
spin-factors = { path = "../factors" }

crates/factor-outbound-redis/src/host.rs

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl v2::HostConnection for crate::InstanceState {
191191
}
192192
});
193193

194-
cmd.query_async::<_, RedisResults>(conn)
194+
cmd.query_async::<RedisResults>(conn)
195195
.await
196196
.map(|values| values.0)
197197
.map_err(other_error)
@@ -296,18 +296,72 @@ struct RedisResults(Vec<RedisResult>);
296296

297297
impl FromRedisValue for RedisResults {
298298
fn from_redis_value(value: &Value) -> redis::RedisResult<Self> {
299-
fn append(values: &mut Vec<RedisResult>, value: &Value) {
299+
fn append(values: &mut Vec<RedisResult>, value: &Value) -> redis::RedisResult<()> {
300300
match value {
301-
Value::Nil | Value::Okay => (),
302-
Value::Int(v) => values.push(RedisResult::Int64(*v)),
303-
Value::Data(bytes) => values.push(RedisResult::Binary(bytes.to_owned())),
304-
Value::Bulk(bulk) => bulk.iter().for_each(|value| append(values, value)),
305-
Value::Status(message) => values.push(RedisResult::Status(message.to_owned())),
301+
Value::Nil => {
302+
values.push(RedisResult::Nil);
303+
Ok(())
304+
}
305+
Value::Int(v) => {
306+
values.push(RedisResult::Int64(*v));
307+
Ok(())
308+
}
309+
Value::BulkString(bytes) => {
310+
values.push(RedisResult::Binary(bytes.to_owned()));
311+
Ok(())
312+
}
313+
Value::SimpleString(s) => {
314+
values.push(RedisResult::Status(s.to_owned()));
315+
Ok(())
316+
}
317+
Value::Okay => {
318+
values.push(RedisResult::Status("OK".to_string()));
319+
Ok(())
320+
}
321+
Value::Map(_) => Err(redis::RedisError::from((
322+
redis::ErrorKind::TypeError,
323+
"Could not convert Redis response",
324+
"Redis Map type is not supported".to_string(),
325+
))),
326+
Value::Attribute { .. } => Err(redis::RedisError::from((
327+
redis::ErrorKind::TypeError,
328+
"Could not convert Redis response",
329+
"Redis Attribute type is not supported".to_string(),
330+
))),
331+
Value::Array(arr) | Value::Set(arr) => {
332+
arr.iter().try_for_each(|value| append(values, value))
333+
}
334+
Value::Double(v) => {
335+
values.push(RedisResult::Binary(v.to_string().into_bytes()));
336+
Ok(())
337+
}
338+
Value::VerbatimString { .. } => Err(redis::RedisError::from((
339+
redis::ErrorKind::TypeError,
340+
"Could not convert Redis response",
341+
"Redis string with format attribute is not supported".to_string(),
342+
))),
343+
Value::Boolean(v) => {
344+
values.push(RedisResult::Int64(if *v { 1 } else { 0 }));
345+
Ok(())
346+
}
347+
Value::BigNumber(v) => {
348+
values.push(RedisResult::Binary(v.to_string().as_bytes().to_owned()));
349+
Ok(())
350+
}
351+
Value::Push { .. } => Err(redis::RedisError::from((
352+
redis::ErrorKind::TypeError,
353+
"Could not convert Redis response",
354+
"Redis Pub/Sub types are not supported".to_string(),
355+
))),
356+
Value::ServerError(err) => Err(redis::RedisError::from((
357+
redis::ErrorKind::ResponseError,
358+
"Server error",
359+
format!("{err:?}"),
360+
))),
306361
}
307362
}
308-
309363
let mut values = Vec::new();
310-
append(&mut values, value);
364+
append(&mut values, value)?;
311365
Ok(RedisResults(values))
312366
}
313367
}

0 commit comments

Comments
 (0)