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
use r2d2;
use {ConnectParams, Connection, HdbError};
#[derive(Debug)]
pub struct ConnectionManager {
connect_params: ConnectParams,
}
impl ConnectionManager {
pub fn new(connect_params: &ConnectParams) -> ConnectionManager {
ConnectionManager {
connect_params: connect_params.clone(),
}
}
}
impl r2d2::ManageConnection for ConnectionManager {
type Connection = Connection;
type Error = HdbError;
fn connect(&self) -> Result<Self::Connection, Self::Error> {
trace!("ConnectionManager::connect()");
Connection::new(self.connect_params.clone())
}
fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error> {
trace!("ConnectionManager::is_valid()");
conn.query("SELECT 1 from dummy").map(|_| ())
}
fn has_broken(&self, _conn: &mut Self::Connection) -> bool {
trace!("ConnectionManager::has_broken()");
false
}
}