Skip to content

Commit

Permalink
Change to exponential retry delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Serock3 committed Dec 1, 2023
1 parent 5aa138f commit 63da800
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mullvad-daemon/src/geoip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ use mullvad_api::{
};
use mullvad_types::location::{AmIMullvad, GeoIpLocation};
use once_cell::sync::Lazy;
use talpid_core::future_retry::{retry_future, ConstantInterval};
use talpid_core::future_retry::{retry_future, ExponentialBackoff, Jittered};
use talpid_types::ErrorExt;

/// Retry interval for fetching location
const RETRY_LOCATION_STRATEGY: ConstantInterval = ConstantInterval::new(Duration::ZERO, Some(3));

// Define the Mullvad connection checking api endpoint.
//
// In a development build the host name for the connection checking endpoint can
Expand Down Expand Up @@ -43,6 +40,9 @@ static MULLVAD_CONNCHECK_HOST: Lazy<String> = Lazy::new(|| {
host.to_string()
});

const LOCATION_RETRY_STRATEGY: Jittered<ExponentialBackoff> =
Jittered::jitter(ExponentialBackoff::new(Duration::from_secs(1), 4));

/// Fetch the current `GeoIpLocation` with retrys
pub async fn get_geo_location(
rest_service: RequestServiceHandle,
Expand All @@ -56,7 +56,7 @@ pub async fn get_geo_location(
Err(error) if error.is_network_error() => !api_handle.get_state().is_offline(),
_ => false,
},
RETRY_LOCATION_STRATEGY,
LOCATION_RETRY_STRATEGY,
)
.await
{
Expand Down

0 comments on commit 63da800

Please sign in to comment.