pub async fn maybe_initialize_server(&self) -> Result<()> {
        let _guard = self
            .initialize_semaphore
            .acquire()
            .await
            .expect("semaphore should not be closed");

        // Note that we use Acquire-Release ordering for the atomic within the semaphore to ensure that another thread
        // that enters this semaphore after we've left actually sees the correct `is_ready` flag.
        if self.initialized.load(Ordering::Acquire) {
            // already loaded, so do nothing
            return Ok(());
        }

        // get the database names from the object store prefixes
        // TODO: update object store to pull back all common prefixes by
        //       following the next tokens.
        let list_result = self
            .store
            .list_with_delimiter(&self.root_path()?)
            .await
            .context(StoreError)?;

        let server_id = self.require_id()?;

        let handles: Vec<_> = list_result
            .common_prefixes
            .into_iter()
            .map(|mut path| {
                let store = Arc::clone(&self.store);
                let config = Arc::clone(&self.config);
                let exec = Arc::clone(&self.exec);

                path.set_file_name(DB_RULES_FILE_NAME);

                tokio::task::spawn(async move {
                    if let Err(e) =
                        Self::load_database_config(server_id, store, config, exec, path).await
                    {
                        error!(%e, "cannot load database");
                    }
                })
            })
            .collect();

        futures::future::join_all(handles).await;

        // mark as ready (use correct ordering for Acquire-Release)
        self.initialized.store(true, Ordering::Release);
        info!("loaded databases, server is initalized");

        Ok(())
    }
/// Loads the database configurations based on the databases in the
/// object store. Any databases in the config already won't be
/// replaced.
///
/// This requires the serverID to be set. It will be a no-op if the configs are already loaded and the server is ready.
Loads the database configurations based on the databases in the
object store. Any databases in the config already won't be
replaced.

This requires the serverID to be set. It will be a no-op if the configs are already loaded and the server is ready.
Loads the database configurations based on the databases in the object store . Any databases in the config already won ' t be replaced . This requires the serverID to be set . It will be a no - op if the configs are already loaded and the server is ready .
pub async fn maybe_initialize_server(&self) -> Result<()> {
        let _guard = self
            .initialize_semaphore
            .acquire()
            .await
            .expect("semaphore should not be closed");
        // Note that we use Acquire-Release ordering for the atomic within the semaphore to ensure that another thread
        // that enters this semaphore after we've left actually sees the correct `is_ready` flag.
        if self.initialized.load(Ordering::Acquire) {
            // already loaded, so do nothing
            return Ok(());
        }
        // get the database names from the object store prefixes
        // TODO: update object store to pull back all common prefixes by
        //       following the next tokens.
        let list_result = self
            .store
            .list_with_delimiter(&self.root_path()?)
            .await
            .context(StoreError)?;
        let server_id = self.require_id()?;
        let handles: Vec<_> = list_result
            .common_prefixes
            .into_iter()
            .map(|mut path| {
                let store = Arc::clone(&self.store);
                let config = Arc::clone(&self.config);
                let exec = Arc::clone(&self.exec);
                path.set_file_name(DB_RULES_FILE_NAME);
                tokio::task::spawn(async move {
                    if let Err(e) =
                        Self::load_database_config(server_id, store, config, exec, path).await
                    {
                        error!(%e, "cannot load database");
                    }
                })
            })
            .collect();
        futures::future::join_all(handles).await;
        // mark as ready (use correct ordering for Acquire-Release)
        self.initialized.store(true, Ordering::Release);
        info!("loaded databases, server is initalized");
        Ok(())
    }
pub async fn maybe_initialize_server ( & self ) -> Result < ( ) > { let _guard = self . initialize_semaphore . acquire ( ) . await . expect ( " " ) ; // Note that we use Acquire-Release ordering for the atomic within the semaphore to ensure that another thread // that enters this semaphore after we've left actually sees the correct `is_ready` flag. if self . initialized . load ( Ordering :: Acquire ) { // already loaded, so do nothing return Ok ( ( ) ) ; } // get the database names from the object store prefixes // TODO: update object store to pull back all common prefixes by //       following the next tokens. let list_result = self . store . list_with_delimiter ( & self . root_path ( ) ? ) . await . context ( StoreError ) ? ; let server_id = self . require_id ( ) ? ; let handles : Vec < _ > = list_result . common_prefixes . into_iter ( ) . map ( | mut path | { let store = Arc :: clone ( & self . store ) ; let config = Arc :: clone ( & self . config ) ; let exec = Arc :: clone ( & self . exec ) ; path . set_file_name ( DB_RULES_FILE_NAME ) ; tokio :: task :: spawn ( async move { if let Err ( e ) = Self :: load_database_config ( server_id , store , config , exec , path ) . await { error ! ( e " " ) ; } } ) } ) . collect ( ) ; futures :: future :: join_all ( handles ) . await ; // mark as ready (use correct ordering for Acquire-Release) self . initialized . store ( true , Ordering :: Release ) ; info ! ( " " ) ; Ok ( ( ) ) }
Loads the database configurations based on the databases in the
object store.
Loads the database configurations based on the databases in the object store .
&self
&self