start method
Future<T>
start({
- TransactionHeaders? headers,
- int maxWait = 2000,
- int timeout = 5000,
- TransactionIsolationLevel? isolationLevel,
Start a new transaction.
Implementation
Future<T> start({
TransactionHeaders? headers,
int maxWait = 2000,
int timeout = 5000,
TransactionIsolationLevel? isolationLevel,
}) async {
if (this.transaction?.id != null) {
throw Exception('Cannot nest start transactions.');
}
headers ??= TransactionHeaders();
headers.traceparent ??= generateTraceparent();
final transaction = await _engine.startTransaction(
headers: headers,
maxWait: maxWait,
timeout: timeout,
isolationLevel: isolationLevel,
);
final client = TransactionClient._(
factory: _factory,
engine: _engine,
headers: headers,
transaction: transaction,
);
return _factory(client);
}