MCPcopy
hub / github.com/mongodb/node-mongodb-native / transition

Method transition

src/transactions.ts:149–166  ·  view source on GitHub ↗

* Transition the transaction in the state machine * @param nextState - The new state to transition to

(nextState: TxnState)

Source from the content-addressed store, hash-verified

147 * @param nextState - The new state to transition to
148 */
149 transition(nextState: TxnState): void {
150 const nextStates = stateMachine[this.state];
151 if (nextStates && nextStates.includes(nextState)) {
152 this.state = nextState;
153 if (
154 this.state === TxnState.NO_TRANSACTION ||
155 this.state === TxnState.STARTING_TRANSACTION ||
156 this.state === TxnState.TRANSACTION_ABORTED
157 ) {
158 this.unpinServer();
159 }
160 return;
161 }
162
163 throw new MongoRuntimeError(
164 `Attempted illegal state transition from [${this.state}] to [${nextState}]`
165 );
166 }
167
168 pinServer(server: Server): void {
169 if (this.isActive) {

Callers 5

startTransactionMethod · 0.80
commitTransactionMethod · 0.80
abortTransactionMethod · 0.80
applySessionFunction · 0.80

Calls 1

unpinServerMethod · 0.95

Tested by

no test coverage detected