pub async fn commit_transaction(&self) -> Result<Vec<DbRecord>, StorageError> {
        debug!("BEGIN commit transaction");
        let mut guard = self.state.write().await;

        if !(*guard).active {
            return Err(StorageError::Transaction(
                "Transaction not currently active".to_string(),
            ));
        }

        // copy all the updated values out
        let mut records = guard.mods.values().cloned().collect::<Vec<_>>();

        // sort according to transaction priority
        records.sort_by_key(|r| r.transaction_priority());

        // flush the trans log
        (*guard).mods.clear();

        (*guard).active = false;
        debug!("END commit transaction");
        Ok(records)
    }
/// Commit a transaction in the storage layer
Commit a transaction in the storage layer
Commit a transaction in the storage layer
pub async fn commit_transaction(&self) -> Result<Vec<DbRecord>, StorageError> {
        debug!("BEGIN commit transaction");
        let mut guard = self.state.write().await;
        if !(*guard).active {
            return Err(StorageError::Transaction(
                "Transaction not currently active".to_string(),
            ));
        }
        // copy all the updated values out
        let mut records = guard.mods.values().cloned().collect::<Vec<_>>();
        // sort according to transaction priority
        records.sort_by_key(|r| r.transaction_priority());
        // flush the trans log
        (*guard).mods.clear();
        (*guard).active = false;
        debug!("END commit transaction");
        Ok(records)
    }
pub async fn commit_transaction ( & self ) -> Result < Vec < DbRecord > , StorageError > { debug ! ( " " ) ; let mut guard = self . state . write ( ) . await ; if ! ( * guard ) . active { return Err ( StorageError :: Transaction ( " " . to_string ( ) , ) ) ; } // copy all the updated values out let mut records = guard . mods . values ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ; // sort according to transaction priority records . sort_by_key ( | r | r . transaction_priority ( ) ) ; // flush the trans log ( * guard ) . mods . clear ( ) ; ( * guard ) . active = false ; debug ! ( " " ) ; Ok ( records ) }
Commit a transaction in the storage layer
Commit a transaction in the storage layer
&self
&self