@@ -6,7 +6,6 @@ use std::time::Duration;
66
77use iron:: Iron ;
88use log:: debug;
9- use r2d2_redis:: RedisConnectionManager ;
109use redis:: { ConnectionInfo , IntoConnectionInfo } ;
1110use router:: Router ;
1211
@@ -24,7 +23,7 @@ use crate::types::RedisPool;
2423
2524enum RedisInfo {
2625 None ,
27- Pool ( r2d2:: Pool < r2d2_redis :: RedisConnectionManager > ) ,
26+ Pool ( r2d2:: Pool < redis :: Client > ) ,
2827 ConnectionInfo ( ConnectionInfo ) ,
2928 Err ( SpaceapiServerError ) ,
3029}
@@ -86,7 +85,7 @@ impl SpaceapiServerBuilder {
8685 /// See
8786 /// [`examples/with_custom_redis_pool.rs`](https://github.com/spaceapi-community/spaceapi-server-rs/blob/master/examples/with_custom_redis_pool.rs)
8887 /// for a real example.
89- pub fn redis_pool ( mut self , redis_pool : r2d2:: Pool < r2d2_redis :: RedisConnectionManager > ) -> Self {
88+ pub fn redis_pool ( mut self , redis_pool : r2d2:: Pool < redis :: Client > ) -> Self {
9089 self . redis_info = RedisInfo :: Pool ( redis_pool) ;
9190 self
9291 }
@@ -125,12 +124,11 @@ impl SpaceapiServerBuilder {
125124 RedisInfo :: Pool ( p) => Ok ( p) ,
126125 RedisInfo :: ConnectionInfo ( ci) => {
127126 // Log some useful debug information
128- debug ! ( "Connecting to redis database {} at {:?}" , ci. db, ci. addr) ;
127+ debug ! ( "Connecting to redis database {} at {:?}" , ci. redis . db, ci. addr) ;
129128
130- let redis_manager = RedisConnectionManager :: new ( ci) ?;
129+ let client : redis :: Client = redis :: Client :: open ( ci) ?;
131130
132- // Create redis pool
133- let redis_pool = r2d2:: Pool :: builder ( )
131+ let redis_pool: r2d2:: Pool < redis:: Client > = r2d2:: Pool :: builder ( )
134132 // Provide up to 6 connections in connection pool
135133 . max_size ( 6 )
136134 // At least 1 connection must be active
@@ -143,7 +141,7 @@ impl SpaceapiServerBuilder {
143141 . error_handler ( Box :: new ( r2d2:: NopErrorHandler ) )
144142 // Initialize connection pool lazily. This allows the SpaceAPI
145143 // server to work even without a database connection.
146- . build_unchecked ( redis_manager ) ;
144+ . build_unchecked ( client ) ;
147145 Ok ( redis_pool)
148146 }
149147 } ;
0 commit comments