Skip to content

Commit 820a531

Browse files
jonasfjsigurdm
andauthored
Increase concurrency and handle errors better (#8257)
* Increase concurrency and handle errors better * Update app/lib/package/api_export/api_exporter.dart Co-authored-by: Sigurd Meldgaard <[email protected]> --------- Co-authored-by: Sigurd Meldgaard <[email protected]>
1 parent 088812e commit 820a531

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/lib/package/api_export/api_exporter.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void registerApiExporter(ApiExporter value) =>
3030
/// The active API Exporter service or null if it hasn't been initialized.
3131
ApiExporter? get apiExporter => ss.lookup(#_apiExporter) as ApiExporter?;
3232

33-
const _concurrency = 30;
33+
const _concurrency = 50;
3434

3535
class ApiExporter {
3636
final ExportedApi _api;
@@ -134,6 +134,7 @@ class ApiExporter {
134134
Future<void> synchronizeExportedApi() async {
135135
final allPackageNames = <String>{};
136136
final packageQuery = dbService.query<Package>();
137+
var errCount = 0;
137138
await packageQuery.run().parallelForEach(_concurrency, (pkg) async {
138139
final name = pkg.name!;
139140
if (pkg.isNotVisible) {
@@ -143,6 +144,9 @@ class ApiExporter {
143144

144145
// TODO: Consider retries around all this logic
145146
await synchronizePackage(name);
147+
}, onError: (e, st) {
148+
_log.warning('synchronizePackage() failed', e, st);
149+
errCount++;
146150
});
147151

148152
await synchronizePackageNameCompletionData();
@@ -157,6 +161,12 @@ class ApiExporter {
157161
});
158162

159163
await _api.garbageCollect(allPackageNames);
164+
165+
if (errCount > 0) {
166+
throw Exception(
167+
'$errCount exceptions happened while calling synchronizeExportedApi',
168+
);
169+
}
160170
}
161171

162172
/// Sync package and into [ExportedApi], this will synchronize package into

app/lib/package/api_export/exported_api.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const _minGarbageAge = Duration(hours: 3);
4444
/// All writes to the bucket containing the exported API should go through this
4545
/// interface.
4646
final class ExportedApi {
47-
final Pool _pool = Pool(50);
47+
final Pool _pool = Pool(80);
4848
final Storage _storage;
4949
final Bucket _bucket;
5050
final List<String> _prefixes = [

0 commit comments

Comments
 (0)