[−][src]Trait tang_rs::Manager
Types for different runtimes:
Trait type runtime Type constructor Manager::Timeout tokio tokio::time::Delay tokio::time::delay_for async-std smol::Timer smol::Timer::after
Manager::TimeoutError tokio () async-std std::time::Instant
Associated Types
type Connection: Unpin + 'static
type Error: Debug + From<Self::TimeoutError> + 'static
type Timeout: Future<Output = Self::TimeoutError> + Send
type TimeoutError: Send + Debug + 'static
Required methods
fn connect(&self) -> ManagerFuture<Result<Self::Connection, Self::Error>>
generate a new connection and put it into pool.
fn is_valid<'a>(
&'a self,
conn: &'a mut Self::Connection
) -> ManagerFuture<'a, Result<(), Self::Error>>
&'a self,
conn: &'a mut Self::Connection
) -> ManagerFuture<'a, Result<(), Self::Error>>
check if a connection is valid.
*. Only called when Builder.always_check == true
fn is_closed(&self, conn: &mut Self::Connection) -> bool
check if a connection is closed.
This happens before a connection put back to pool.
fn spawn<Fut>(&self, fut: Fut) where
Fut: Future<Output = ()> + Send + 'static,
Fut: Future<Output = ()> + Send + 'static,
spawn futures on your executor
The future have to be Send + 'static
and the return type(e.g. JoinHandler) of your executor will be ignored.
fn timeout<Fut: Future>(
&self,
fut: Fut,
_dur: Duration
) -> ManagerTimeout<Fut, Self::Timeout>
&self,
fut: Fut,
_dur: Duration
) -> ManagerTimeout<Fut, Self::Timeout>
Used to cancel futures and return Manager::TimeoutError
.
The duration is determined by Builder.wait_timeout
and Builder.connection_timeout
Provided methods
fn on_start(&self, _shared_pool: &SharedManagedPool<Self>)
This method will be called when Pool<Manager>::init()
executes.
fn on_stop(&self)
This method will be called when Pool<Manager>
is dropping