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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « app/bin/server.dart ('k') | app/bin/tools_common.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library pub_dartlang_org.server_common; 5 library pub_dartlang_org.server_common;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:gcloud/datastore.dart'; 10 import 'package:gcloud/datastore.dart';
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 registerScopeExitCallback(authClient.close); 100 registerScopeExitCallback(authClient.close);
101 101
102 final datastore = new DatastoreImpl(authClient, projectId); 102 final datastore = new DatastoreImpl(authClient, projectId);
103 registerDatastoreService(datastore); 103 registerDatastoreService(datastore);
104 104
105 final db = new DatastoreDB(datastore); 105 final db = new DatastoreDB(datastore);
106 registerDbService(db); 106 registerDbService(db);
107 107
108 return db; 108 return db;
109 } 109 }
110
111 /// Wrapper function used to work around issue with running gRPC datastore on
112 /// MacOS.
113 ///
114 /// On
115 /// * linux this function simply returns `fun(dbService)`
116 ///
117 /// * macos this function makes a new service scope, optionally builds an
118 /// apiary datastore and registers an apiary datastore in the new service
119 /// scope
120 ///
121 Future withCorrectDatastore(Future fun(DatastoreDB db), DatastoreDB savedDb) {
122 if (Platform.isMacOS) {
123 return fork(() async {
124 registerDbService(savedDb ?? await initializeApiaryDatastore());
125 return fun(dbService);
126 });
127 } else {
128 assert(dbService != null);
129 return fun(dbService);
130 }
131 }
OLDNEW
« 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