pub trait AsyncCtrl {
// Required methods
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SinkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn reconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SinkResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Runtime control trait for managing sink lifecycle.
Implementors must ensure all methods are idempotent - calling them multiple times should be safe and produce consistent results.
§Example
ⓘ
#[async_trait]
impl AsyncCtrl for MySink {
async fn stop(&mut self) -> SinkResult<()> {
self.connection.close().await?;
Ok(())
}
async fn reconnect(&mut self) -> SinkResult<()> {
self.connection = Connection::new(&self.config).await?;
Ok(())
}
}Required Methods§
Sourcefn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SinkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SinkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gracefully stop the sink and release all resources.
This method must be idempotent - subsequent calls should return Ok(())
without side effects. After calling stop(), the sink should not accept
any more data.
Sourcefn reconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SinkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = SinkResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reconnect or refresh the sink’s underlying connection.
Use this to recover from transient failures without recreating the sink. The method should preserve any configuration and state that doesn’t depend on the connection itself.