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
use std::time::{Duration, Instant};
use future::{self, BoxFuture};
use futures::prelude::*;
use crate::{error::Error, Ping, PingState, Poolable};
pub trait ConnectionFactory {
type Connection: Poolable;
fn create_connection(&self) -> BoxFuture<Result<Self::Connection, Error>>;
fn connecting_to(&self) -> &str;
fn ping(&self, _timeout: Instant) -> BoxFuture<Ping> {
future::ready(Ping {
connect_time: None,
latency: None,
total_time: Duration::default(),
uri: self.connecting_to().to_owned(),
state: PingState::failed_msg("pinging is not supported by this connection factory"),
})
.boxed()
}
}