Skip to content

Commit 19f9e70

Browse files
authored
Added redis cluster support (redis-rs#239)
This adds basic redis cluster support.
1 parent 24ac057 commit 19f9e70

File tree

15 files changed

+1343
-31
lines changed

15 files changed

+1343
-31
lines changed

Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ futures-executor = "0.3.0"
2727
pin-project-lite = "0.1"
2828
tokio-util = { version = "0.2", features = ["codec"] }
2929
tokio = { version = "0.2", features = ["tcp", "uds", "io-util", "sync", "stream"] }
30+
crc16 = { version = "0.4.0", optional = true }
31+
rand = { version = "0.7.0", optional = true }
3032

3133
[features]
32-
default = [ "geospatial" ]
33-
34+
default = ["geospatial"]
3435
tokio-rt-core = ["tokio/rt-core"]
35-
3636
geospatial = []
37+
cluster = ["crc16", "rand"]
3738

3839
[dev-dependencies]
3940
rand = "0.7"
@@ -45,8 +46,6 @@ criterion = "0.3"
4546
partial-io = { version = "0.3", features = ["tokio", "quickcheck"] }
4647
quickcheck = "0.6"
4748
tokio = { version = "0.2", features = ["rt-core", "macros"] }
48-
# End of dev-dependencies
49-
5049

5150
[[test]]
5251
name = "test_async"

LICENSE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Copyright (c) 2013 by Armin Ronacher.
1+
Copyright (c) 2013-2019 by Armin Ronacher, Jan-Erik Rediger.
2+
3+
Redis cluster code in parts copyright (c) 2018 by Atsushi Koge.
24

35
Some rights reserved.
46

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test:
1212
@echo "===================================================================="
1313
@echo "Testing Connection Type UNIX SOCKETS"
1414
@echo "===================================================================="
15-
@REDISRS_SERVER_TYPE=unix cargo test --all-features
15+
@REDISRS_SERVER_TYPE=unix cargo test --all-features -- --skip test_cluster
1616

1717
test-single: RUST_TEST_THREADS=1
1818
test-single: test

src/client.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,20 @@ impl ConnectionLike for Client {
106106
fn get_db(&self) -> i64 {
107107
self.connection_info.db
108108
}
109+
110+
fn check_connection(&mut self) -> bool {
111+
if let Ok(mut conn) = self.get_connection() {
112+
conn.check_connection()
113+
} else {
114+
false
115+
}
116+
}
117+
118+
fn is_open(&self) -> bool {
119+
if let Ok(conn) = self.get_connection() {
120+
conn.is_open()
121+
} else {
122+
false
123+
}
124+
}
109125
}

0 commit comments

Comments
 (0)