-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Labels
team-infraOwned by Infrastructure teamOwned by Infrastructure team
Description
One way I to reduce the nesting scope it to have datastore.dart implement it's own withTransaction function and we switch the Cocoon usage to use that function.
For example this PR has:
await runTransactionWithRetries(() async {
await datastore.db
.withTransaction<void>((Transaction transaction) async {
final TimeSeries series =
await _getOrCreateTimeSeries(transaction, task, scoreKey);
final num value = resultData[scoreKey] as num;
final TimeSeriesValue seriesValue = TimeSeriesValue(
key: series.key.append(TimeSeriesValue),
createTimestamp: DateTime.now().millisecondsSinceEpoch,
revision: commit.sha,
taskKey: task.key,
value: value.toDouble(),
);
transaction.queueMutations(inserts: <TimeSeriesValue>[seriesValue]);
await transaction.commit();
});
});
instead we could do:
final TimeSeries series = await _getOrCreateTimeSeries(transaction, task, scoreKey);
final num value = resultData[scoreKey] as num;
final TimeSeriesValue seriesValue = TimeSeriesValue(
key: series.key.append(TimeSeriesValue),
createTimestamp: DateTime.now().millisecondsSinceEpoch,
revision: commit.sha,
taskKey: task.key,
value: value.toDouble(),
);
await datastore.withTransaction(insert: [seriesValue]); // this being the end goal of removing the extra nesting
Metadata
Metadata
Assignees
Labels
team-infraOwned by Infrastructure teamOwned by Infrastructure team