1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
use std::time::Duration;
use futures::{future::Future, try_ready, Async, Poll};
use redis::{r#async::Connection, Client};
use crate::error::ReoolError;
use crate::pool::{
Checkout as PoolCheckout, ConnectionFactory, ConnectionFactoryFuture, NewConnectionError,
Poolable,
};
mod backoff_strategy;
mod commands;
mod error;
pub(crate) mod executor_flavour;
pub(crate) mod helpers;
pub mod instrumentation;
pub mod multi_node_pool;
pub mod node_pool;
mod pool;
mod pooled_connection;
pub use commands::*;
pub use pooled_connection::PooledConnection;
pub struct Checkout(PoolCheckout<Connection>);
impl Future for Checkout {
type Item = PooledConnection;
type Error = ReoolError;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
let managed = try_ready!(self.0.poll());
Ok(Async::Ready(PooledConnection {
managed,
last_op_completed: true,
}))
}
}
pub trait RedisPool {
fn check_out(&self) -> Checkout;
fn check_out_explicit_timeout(&self, timeout: Option<Duration>) -> Checkout;
}
impl Poolable for Connection {}
impl ConnectionFactory for Client {
type Connection = Connection;
fn create_connection(&self) -> ConnectionFactoryFuture<Self::Connection> {
Box::new(
self.get_async_connection()
.map_err(|err| NewConnectionError::new(err)),
)
}
}