Skip to content

Commit dddfc12

Browse files
committed
Added support for redis+unix as url scheme
1 parent 16b7aec commit dddfc12

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/connection.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ static DEFAULT_PORT: u16 = 6379;
2727
pub fn parse_redis_url(input: &str) -> Result<url::Url, ()> {
2828
match url::Url::parse(input) {
2929
Ok(result) => {
30-
if result.scheme() == "redis" || result.scheme() == "unix" {
31-
Ok(result)
32-
} else {
33-
Err(())
30+
match result.scheme() {
31+
"redis" | "redis+unix" | "unix" => Ok(result),
32+
_ => Err(())
3433
}
3534
},
3635
Err(_) => Err(()),
@@ -62,7 +61,7 @@ impl ConnectionAddr {
6261
#[cfg(any(feature="with-unix-sockets", feature="with-system-unix-sockets"))]
6362
ConnectionAddr::Unix(_) => true,
6463
#[cfg(not(any(feature="with-unix-sockets", feature="with-system-unix-sockets")))]
65-
ConnectionAddr::Unix(_) => false,
64+
ConnectionInfo::Unix(_) => false,
6665
}
6766
}
6867
}
@@ -145,7 +144,7 @@ impl IntoConnectionInfo for url::Url {
145144
fn into_connection_info(self) -> RedisResult<ConnectionInfo> {
146145
if self.scheme() == "redis" {
147146
url_to_tcp_connection_info(self)
148-
} else if self.scheme() == "unix" {
147+
} else if self.scheme() == "unix" || self.scheme() == "redis+unix" {
149148
url_to_unix_connection_info(self)
150149
} else {
151150
fail!((ErrorKind::InvalidClientConfig, "URL provided is not a redis URL"));

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
//! In case the create is compiled with Unix socket support you can also
7878
//! use a unix URL in this format:
7979
//!
80+
//! `redis+unix:///[:<passwd>@]<path>[?db=<db>]`
81+
//!
82+
//! For compatibility with some other redis libraries, the "unix" scheme
83+
//! is also supported:
84+
//!
8085
//! `unix:///[:<passwd>@]<path>[?db=<db>]`
8186
//!
8287
//! ## Executing Low-Level Commands

0 commit comments

Comments
 (0)