pub async fn create_database(&self, rules: DatabaseRules) -> Result<()> {
        // Return an error if this server is not yet ready
        let config = self.require_initialized()?;

        // Reserve name before expensive IO (e.g. loading the preserved catalog)
        let mut db_reservation = config.create_db(rules.name.clone())?;

        // register rules
        db_reservation.advance_rules_loaded(rules.clone())?;

        // load preserved catalog
        let (preserved_catalog, catalog, replay_plan) = create_preserved_catalog(
            rules.db_name(),
            Arc::clone(self.application.object_store()),
            config.server_id(),
            Arc::clone(self.application.metric_registry()),
        )
        .await
        .map_err(|e| Box::new(e) as _)
        .context(CannotCreatePreservedCatalog)?;

        let write_buffer = WriteBufferConfig::new(config.server_id(), &rules)
            .await
            .map_err(|e| Error::CreatingWriteBuffer {
                config: rules.write_buffer_connection.clone(),
                source: e,
            })?;
        info!(write_buffer_enabled=?write_buffer.is_some(), db_name=rules.db_name(), "write buffer config");
        db_reservation.advance_replay(preserved_catalog, catalog, replay_plan, write_buffer)?;

        // no actual replay required
        let db = db_reservation
            .db_any_state()
            .expect("DB should exist at this point");
        db.unsuppress_persistence().await;
        db.allow_write_buffer_read();
        db_reservation.advance_init()?;

        // ready to commit
        self.persist_database_rules(rules.clone()).await?;
        db_reservation.commit();

        Ok(())
    }
/// Tells the server the set of rules for a database.
Tells the server the set of rules for a database.
Tells the server the set of rules for a database .
pub async fn create_database(&self, rules: DatabaseRules) -> Result<()> {
        // Return an error if this server is not yet ready
        let config = self.require_initialized()?;
        // Reserve name before expensive IO (e.g. loading the preserved catalog)
        let mut db_reservation = config.create_db(rules.name.clone())?;
        // register rules
        db_reservation.advance_rules_loaded(rules.clone())?;
        // load preserved catalog
        let (preserved_catalog, catalog, replay_plan) = create_preserved_catalog(
            rules.db_name(),
            Arc::clone(self.application.object_store()),
            config.server_id(),
            Arc::clone(self.application.metric_registry()),
        )
        .await
        .map_err(|e| Box::new(e) as _)
        .context(CannotCreatePreservedCatalog)?;
        let write_buffer = WriteBufferConfig::new(config.server_id(), &rules)
            .await
            .map_err(|e| Error::CreatingWriteBuffer {
                config: rules.write_buffer_connection.clone(),
                source: e,
            })?;
        info!(write_buffer_enabled=?write_buffer.is_some(), db_name=rules.db_name(), "write buffer config");
        db_reservation.advance_replay(preserved_catalog, catalog, replay_plan, write_buffer)?;
        // no actual replay required
        let db = db_reservation
            .db_any_state()
            .expect("DB should exist at this point");
        db.unsuppress_persistence().await;
        db.allow_write_buffer_read();
        db_reservation.advance_init()?;
        // ready to commit
        self.persist_database_rules(rules.clone()).await?;
        db_reservation.commit();
        Ok(())
    }
pub async fn create_database ( & self , rules : DatabaseRules ) -> Result < ( ) > { // Return an error if this server is not yet ready let config = self . require_initialized ( ) ? ; // Reserve name before expensive IO (e.g. loading the preserved catalog) let mut db_reservation = config . create_db ( rules . name . clone ( ) ) ? ; // register rules db_reservation . advance_rules_loaded ( rules . clone ( ) ) ? ; // load preserved catalog let ( preserved_catalog , catalog , replay_plan ) = create_preserved_catalog ( rules . db_name ( ) , Arc :: clone ( self . application . object_store ( ) ) , config . server_id ( ) , Arc :: clone ( self . application . metric_registry ( ) ) , ) . await . map_err ( | e | Box :: new ( e ) as _ ) . context ( CannotCreatePreservedCatalog ) ? ; let write_buffer = WriteBufferConfig :: new ( config . server_id ( ) , & rules ) . await . map_err ( | e | Error :: CreatingWriteBuffer { config : rules . write_buffer_connection . clone ( ) , source : e , } ) ? ; info ! ( write_buffer_enabled write_buffer is_some ( ) db_name rules db_name ( ) " " ) ; db_reservation . advance_replay ( preserved_catalog , catalog , replay_plan , write_buffer ) ? ; // no actual replay required let db = db_reservation . db_any_state ( ) . expect ( " " ) ; db . unsuppress_persistence ( ) . await ; db . allow_write_buffer_read ( ) ; db_reservation . advance_init ( ) ? ; // ready to commit self . persist_database_rules ( rules . clone ( ) ) . await ? ; db_reservation . commit ( ) ; Ok ( ( ) ) }
Tells the server the set of rules for a database.
Tells the server the set of rules for a database .
&self
rules
DatabaseRules
&self
rules
DatabaseRules