Renamed reconnection backoff to initial reconnection backoff
This commit is contained in:
@@ -17,13 +17,13 @@ pub(crate) struct ConnectionReconnector<'a> {
|
||||
current_backoff_delay: tokio::time::Delay,
|
||||
maximum_reconnection_backoff: Duration,
|
||||
|
||||
reconnection_backoff: Duration,
|
||||
initial_reconnection_backoff: Duration,
|
||||
}
|
||||
|
||||
impl<'a> ConnectionReconnector<'a> {
|
||||
pub(crate) fn new(
|
||||
address: SocketAddr,
|
||||
reconnection_backoff: Duration,
|
||||
initial_reconnection_backoff: Duration,
|
||||
maximum_reconnection_backoff: Duration,
|
||||
) -> ConnectionReconnector<'a> {
|
||||
ConnectionReconnector {
|
||||
@@ -32,7 +32,7 @@ impl<'a> ConnectionReconnector<'a> {
|
||||
current_backoff_delay: tokio::time::delay_for(Duration::new(0, 0)), // if we can re-establish connection on first try without any backoff that's perfect
|
||||
current_retry_attempt: 0,
|
||||
maximum_reconnection_backoff,
|
||||
reconnection_backoff,
|
||||
initial_reconnection_backoff,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ impl<'a> Future for ConnectionReconnector<'a> {
|
||||
// we failed to re-establish connection - continue exponential backoff
|
||||
let next_delay = std::cmp::min(
|
||||
self.maximum_reconnection_backoff,
|
||||
2_u32.pow(self.current_retry_attempt) * self.reconnection_backoff,
|
||||
2_u32.pow(self.current_retry_attempt) * self.initial_reconnection_backoff,
|
||||
);
|
||||
|
||||
self.current_backoff_delay
|
||||
|
||||
@@ -9,19 +9,19 @@ mod connection_manager;
|
||||
|
||||
pub struct Config {
|
||||
initial_endpoints: Vec<SocketAddr>,
|
||||
reconnection_backoff: Duration,
|
||||
initial_reconnection_backoff: Duration,
|
||||
maximum_reconnection_backoff: Duration,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn new(
|
||||
initial_endpoints: Vec<SocketAddr>,
|
||||
reconnection_backoff: Duration,
|
||||
initial_reconnection_backoff: Duration,
|
||||
maximum_reconnection_backoff: Duration,
|
||||
) -> Self {
|
||||
Config {
|
||||
initial_endpoints,
|
||||
reconnection_backoff,
|
||||
initial_reconnection_backoff,
|
||||
maximum_reconnection_backoff,
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ impl Config {
|
||||
pub struct Client<'a> {
|
||||
connections_managers: HashMap<SocketAddr, ConnectionManager<'a>>,
|
||||
maximum_reconnection_backoff: Duration,
|
||||
reconnection_backoff: Duration,
|
||||
initial_reconnection_backoff: Duration,
|
||||
}
|
||||
|
||||
impl<'a> Client<'a> {
|
||||
@@ -41,7 +41,7 @@ impl<'a> Client<'a> {
|
||||
initial_endpoint,
|
||||
ConnectionManager::new(
|
||||
initial_endpoint,
|
||||
config.reconnection_backoff,
|
||||
config.initial_reconnection_backoff,
|
||||
config.maximum_reconnection_backoff,
|
||||
)
|
||||
.await,
|
||||
@@ -50,8 +50,8 @@ impl<'a> Client<'a> {
|
||||
|
||||
Client {
|
||||
connections_managers,
|
||||
reconnection_backoff: config.maximum_reconnection_backoff,
|
||||
maximum_reconnection_backoff: config.reconnection_backoff,
|
||||
initial_reconnection_backoff: config.maximum_reconnection_backoff,
|
||||
maximum_reconnection_backoff: config.initial_reconnection_backoff,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ impl<'a> Client<'a> {
|
||||
// so that other connections could progress
|
||||
let new_manager = ConnectionManager::new(
|
||||
address,
|
||||
self.reconnection_backoff,
|
||||
self.initial_reconnection_backoff,
|
||||
self.maximum_reconnection_backoff,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -14,12 +14,12 @@ pub(crate) struct PacketForwarder<'a> {
|
||||
impl<'a: 'static> PacketForwarder<'a> {
|
||||
pub(crate) async fn new(
|
||||
initial_endpoints: Vec<SocketAddr>,
|
||||
reconnection_backoff: Duration,
|
||||
initial_reconnection_backoff: Duration,
|
||||
maximum_reconnection_backoff: Duration,
|
||||
) -> PacketForwarder<'a> {
|
||||
let tcp_client_config = multi_tcp_client::Config::new(
|
||||
initial_endpoints,
|
||||
reconnection_backoff,
|
||||
initial_reconnection_backoff,
|
||||
maximum_reconnection_backoff,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user