MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / begin_transaction

Method begin_transaction

graphlite/src/session/transaction_state.rs:100–126  ·  view source on GitHub ↗

Begin a new transaction

(&self)

Source from the content-addressed store, hash-verified

98
99 /// Begin a new transaction
100 pub fn begin_transaction(&self) -> Result<TransactionId, ExecutionError> {
101 // Check if there's already an active transaction
102 if self.has_active_transaction()? {
103 return Err(ExecutionError::RuntimeError(
104 "Transaction already in progress".to_string(),
105 ));
106 }
107
108 // Start a new transaction
109 let isolation = self.isolation_level()?;
110 let txn_id = self.manager.start_transaction(Some(isolation), None)?;
111
112 // Set as current transaction
113 let mut current = self.current_transaction.write().map_err(|_| {
114 ExecutionError::RuntimeError("Failed to update transaction state".to_string())
115 })?;
116 *current = Some(txn_id);
117
118 // Initialize transaction log
119 let mut logs = self.transaction_logs.write().map_err(|_| {
120 ExecutionError::RuntimeError("Failed to update transaction logs".to_string())
121 })?;
122 logs.insert(txn_id, TransactionLog::new(txn_id));
123
124 log::info!("Session began transaction: {:?}", txn_id);
125 Ok(txn_id)
126 }
127
128 /// Commit the current transaction
129 pub fn commit_transaction(&self) -> Result<(), ExecutionError> {

Callers 2

Calls 4

isolation_levelMethod · 0.80
start_transactionMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected