Function setup_async

Source
pub async fn setup_async() -> Result<AutoShutdown, Err>
Expand description

Executes asynchronously 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. The setup can run synchronously or asynchronously using an AsyncGroup if operations are time-consuming.

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

If all data source setups are successful, the Result::Ok which contains an 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, Err>: An AutoShutdown if all global data sources are set up successfully, or an Err if any setup fails.