I am not sure whether I am missing any, after following the instructions given in https://cloud.google.com/datastore/docs/tools/datastore-emulator
I was not able to connect to local emulator unless I create Datastore explicitly using DataStoreClient.
DatastoreDb db = DatastoreDb.Create(projectId, string.Empty, new DatastoreClientImpl(
new Datastore.DatastoreClient(
new Channel("localhost", 8081, ChannelCredentials.Insecure)), new DatastoreSettings()));
instead of just DatastoreDb.Create(projectId);
If we are working in GKE for production, we need to connect to actual Datastore not an emulator, how do we differentiate between the two versions with same code base.
Is there a way to check if code is running GKE, or is this something that should be done via by an environment variable for best results.
You can use the
Platform
class in theGoogle.Api.Gax
namespace (in theGoogle.Api.Gax
package):