pub fn new(
        factory: Factory,
        strategy: Option<NewStrategy>,
        connect_now: bool,
    ) -> Result<Self, Error<FactoryError, Slave::Err>> {
        let result = Self {
            slave: RefCell::new(None),
            factory,
            strategy: strategy.unwrap_or_else(|| Box::new(|| default_new_strategy())),
            initialized: Cell::new(false),
        };
        if connect_now {
            result
                .init(&mut result.slave.borrow_mut(), &mut (result.strategy)())
                .map_err(|factory| {
                    Error {
                        factory,
                        slave: None,
                    }
                })?;
        }
        Ok(result)
    }
/// Creates a new retry adapter.
///
/// # Parameters
///
/// * `factory`: A factory function that is used to produce new instance of the slave drain on
///   every (re)connection attempt.
/// * `strategy`: A reconnect strategy, describing how long to wait between attempts and how
///   many attempts to make. If set to `None` a default strategy with 4 increasingly delayed
///   attemps is used.
/// * `connect_now`: Should a connection be made right away. If it is set to `true`, it may
///   block (it uses the reconnect strategy provided) and it may return an error. If set to
///   `false`, the connection is made on the first logged message. No matter if connecting now
///   or later, the first connection attempt is without waiting.
Creates a new retry adapter.
Creates a new retry adapter .
pub fn new(
        factory: Factory,
        strategy: Option<NewStrategy>,
        connect_now: bool,
    ) -> Result<Self, Error<FactoryError, Slave::Err>> {
        let result = Self {
            slave: RefCell::new(None),
            factory,
            strategy: strategy.unwrap_or_else(|| Box::new(|| default_new_strategy())),
            initialized: Cell::new(false),
        };
        if connect_now {
            result
                .init(&mut result.slave.borrow_mut(), &mut (result.strategy)())
                .map_err(|factory| {
                    Error {
                        factory,
                        slave: None,
                    }
                })?;
        }
        Ok(result)
    }
pub fn new ( factory : Factory , strategy : Option < NewStrategy > , connect_now : bool , ) -> Result < Self , Error < FactoryError , Slave :: Err > > { let result = Self { slave : RefCell :: new ( None ) , factory , strategy : strategy . unwrap_or_else ( | | Box :: new ( | | default_new_strategy ( ) ) ) , initialized : Cell :: new ( false ) , } ; if connect_now { result . init ( & mut result . slave . borrow_mut ( ) , & mut ( result . strategy ) ( ) ) . map_err ( | factory | { Error { factory , slave : None , } } ) ? ; } Ok ( result ) }
Creates a new retry adapter.
Creates a new retry adapter .
factory
Factory
strategy
Option<NewStrategy>
connect_now
bool
factory
Factory
strategy
Option<NewStrategy>
connect_now
bool