pub trait DataSrc<C>where
C: DataConn + 'static,{
// Required methods
fn setup(&mut self, ag: &mut AsyncGroup) -> Result<()>;
fn close(&mut self);
fn create_data_conn(&mut self) -> Result<Box<C>>;
}Expand description
The trait that abstracts a data source responsible for managing connections to external data services, such as databases, file systems, or messaging services.
It receives configuration for connecting to an external data service and then
creates and supplies DataConn instance, representing a single session connection.
Required Methods§
Sourcefn setup(&mut self, ag: &mut AsyncGroup) -> Result<()>
fn setup(&mut self, ag: &mut AsyncGroup) -> Result<()>
Performs the setup process for the data source.
This method is responsible for establishing global connections, configuring
connection pools, or performing any necessary initializations required
before DataConn instances can be created.
§Parameters
ag: A mutable reference to anAsyncGroup. This is used if the setup process is potentially time-consuming and can benefit from concurrent execution in a separate thread.
§Returns
errs::Result<()>:Ok(())if the setup is successful, or anerrs::Errif any part of the setup fails.
Sourcefn close(&mut self)
fn close(&mut self)
Closes the data source and releases any globally held resources.
This method should perform cleanup operations, such as closing global connections or shutting down connection pools, that were established during the setup process.