use std::sync::Arc;
use std::time::Duration;
pub trait RetryTimerProvider: Send + Sync {
fn sleep(&self, duration: Duration);
}
pub trait RetryTimerProviderDebug: RetryTimerProvider + std::fmt::Debug {}
impl<T: RetryTimerProvider + std::fmt::Debug> RetryTimerProviderDebug for T {}
#[derive(Debug, Clone)]
pub struct ProductionRetryTimer;
impl RetryTimerProvider for ProductionRetryTimer {
fn sleep(&self, duration: Duration) {
std::thread::sleep(duration);
}
}
pub fn production_timer() -> Arc<dyn RetryTimerProviderDebug> {
Arc::new(ProductionRetryTimer)
}
pub fn do_sleep(duration: Duration) {
std::thread::sleep(duration);
}
pub fn get_env_var(key: &str) -> Option<String> {
std::env::var(key).ok()
}