Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: app/bin/server_common.dart

Issue 2840533002: Add a helper function to ensure we have the correct datastore installed
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/bin/server.dart ('k') | app/bin/tools_common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/bin/server_common.dart
diff --git a/app/bin/server_common.dart b/app/bin/server_common.dart
index bb3a6b4211911e44910ec05afd5f31fdbfc923ee..a7640f26449804f97c5473592b53180609f71100 100644
--- a/app/bin/server_common.dart
+++ b/app/bin/server_common.dart
@@ -107,3 +107,25 @@ Future<DatastoreDB> initializeApiaryDatastore() async {
return db;
}
+
+/// Wrapper function used to work around issue with running gRPC datastore on
+/// MacOS.
+///
+/// On
+/// * linux this function simply returns `fun(dbService)`
+///
+/// * macos this function makes a new service scope, optionally builds an
+/// apiary datastore and registers an apiary datastore in the new service
+/// scope
+///
+Future withCorrectDatastore(Future fun(DatastoreDB db), DatastoreDB savedDb) {
+ if (Platform.isMacOS) {
+ return fork(() async {
+ registerDbService(savedDb ?? await initializeApiaryDatastore());
+ return fun(dbService);
+ });
+ } else {
+ assert(dbService != null);
+ return fun(dbService);
+ }
+}
« no previous file with comments | « app/bin/server.dart ('k') | app/bin/tools_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698