Skip to main content

setup

Function setup 

Source
pub fn setup() -> Result<AutoShutdown>
Expand description

Executes the setup process for all globally registered data sources.

This setup typically involves tasks such as creating connection pools, opening global connections, or performing initial configurations necessary for creating session-specific connections.

If any data source fails to set up, this function returns an errs::Err with DataSrcError::FailToSetupGlobalDataSrcs, containing a vector of the names of the failed data sources and their corresponding errs::Err objects. In such a case, all global data sources that were successfully set up are also closed.

If all data source setups are successful, the Result::Ok which contains an AutoShutdown object is returned. This object is designed to close and drop global data sources when it’s dropped. Thanks to Rust’s ownership mechanism, this ensures that the global data sources are automatically cleaned up when the return value goes out of scope.

NOTE: Do not receive the Result or its inner object into an anonymous variable using let _ = .... If you do, the inner object is dropped immediately at that point.

§Returns

  • Result<AutoShutdown, errs::Err>: An AutoShutdown if all global data sources are set up successfully, or an errs::Err if any setup fails.