From 511d12c152086a222527addc21cc68d219463a6c Mon Sep 17 00:00:00 2001 From: Muhamad Azamy Date: Tue, 11 Apr 2023 15:25:43 +0200 Subject: [PATCH] update bb8_redis this was needed to support ipv6 url --- Cargo.lock | 38 +++++++++++++------------------------- Cargo.toml | 2 +- src/cache/mod.rs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 675a3fa..2d818a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,9 +117,9 @@ dependencies = [ [[package]] name = "bb8-redis" -version = "0.11.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b081e2864000416c5a4543fed63fb8dd979c4a0806b071fddab0e548c6cd4c74" +checksum = "688ba412f8e9c4a7e131774a94bf5a95df12618d143981b97d2aaf0776815533" dependencies = [ "async-trait", "bb8", @@ -342,12 +342,6 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" -[[package]] -name = "dtoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" - [[package]] name = "either" version = "1.6.1" @@ -650,7 +644,7 @@ checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" dependencies = [ "bytes", "fnv", - "itoa 1.0.1", + "itoa", ] [[package]] @@ -691,7 +685,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.1", + "itoa", "pin-project-lite", "socket2", "tokio", @@ -757,12 +751,6 @@ dependencies = [ "either", ] -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - [[package]] name = "itoa" version = "1.0.1" @@ -1163,20 +1151,20 @@ dependencies = [ [[package]] name = "redis" -version = "0.21.5" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a80b5f38d7f5a020856a0e16e40a9cfabf88ae8f0e4c2dcd8a3114c1e470852" +checksum = "3ea8c51b5dc1d8e5fd3350ec8167f464ec0995e79f2e90a075b63371500d557f" dependencies = [ "async-trait", "bytes", "combine", - "dtoa", "futures-util", - "itoa 0.4.8", + "itoa", "percent-encoding", "pin-project-lite", + "ryu", "tokio", - "tokio-util 0.6.9", + "tokio-util 0.7.1", "url", ] @@ -1370,7 +1358,7 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ - "itoa 1.0.1", + "itoa", "ryu", "serde", ] @@ -1382,7 +1370,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.1", + "itoa", "ryu", "serde", ] @@ -1500,7 +1488,7 @@ dependencies = [ "hashlink", "hex", "indexmap", - "itoa 1.0.1", + "itoa", "libc", "libsqlite3-sys", "log", @@ -1667,7 +1655,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" dependencies = [ - "itoa 1.0.1", + "itoa", "libc", "num_threads", "time-macros", diff --git a/Cargo.toml b/Cargo.toml index 45e991c..cab0702 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ tar = "0.4" flate2 = "1.0" snap = "1.0.5" async-recursion = "1.0.0" -bb8-redis = "0.11.0" +bb8-redis = "0.13" async-trait = "0.1.53" url = "2.3.1" # next are only needed for the binarys diff --git a/src/cache/mod.rs b/src/cache/mod.rs index c5e8095..5c85dd0 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -64,6 +64,7 @@ impl Cache { u.set_path(""); + log::debug!("switching namespace to: {:?}", namespace); let mgr = RedisConnectionManager::new(u)?; let namespace = WithNamespace { namespace }; let pool = Pool::builder() @@ -199,3 +200,34 @@ impl Locker { Ok(()) } } + +#[cfg(test)] +mod test { + #[test] + fn test_url() { + let mut u = + url::Url::parse("redis://[2001:728:1000:402:70b4:a3ff:fe89:bf13]:9900/604-22888-zdb1") + .unwrap(); + let namespace: Option = match u.path_segments() { + None => None, + Some(mut segments) => segments.next().map(|s| s.to_owned()), + }; + + assert!(matches!(namespace, Some(ref s) if s == "604-22888-zdb1")); + + u.set_path(""); + + assert_eq!( + u.to_string(), + "redis://[2001:728:1000:402:70b4:a3ff:fe89:bf13]:9900" + ); + } + + #[test] + fn test_redis() { + use bb8_redis::redis::{cmd, Client}; + let mut con = Client::open("redis://[2001:728:1000:402:70b4:a3ff:fe89:bf13]:9900").unwrap(); + + let _: () = cmd("PING").query(&mut con).unwrap(); + } +}