1
votes

I've GAE application which creates some data in the Google Cloud Datastore and stores some binary files into the Google Cloud Storage - let's call the application WebApp. Now I have a different application running on the Google compute engine. Let's call the application ComputeApp.

The ComputeApp is a backend process which is processing data created by the WebApp. I asked here in this question previously which API can I use to communicate with Datastore from the ComputeApp. As suggested by @proppy, I implemented the Datastore communication using of the Google Cloud Datastore API.

Everything works fine as far as I'm communicating with the Datastore in the Google cloud. I'm using the service account authentication.

Now I need to run my ComputeApp locally, on my development PC so I'll take data created by my local WebApp and stored into the local debug Datastore. I need it because I want to have a testing environment so I can debug may GAE app locally.

How should I modify my ComputeApp code to force it to connect to my local debug Datastore instead of connect to the Google cloud?

I googled a lot and didn't find any advice nor example. Only possible way I found that I should rewrite my code completely and use a different API to do that. Such is Datastore Remote API. Is this really only way? Should I really rewrite whole ComputeApp to connect to the local DB? Really?

I hope that I just overlooked something important and It's not true...

1

1 Answers

2
votes

Google Cloud Datastore has a local development server that you can use: https://developers.google.com/datastore/docs/tools/devserver

You can create and start the local datastore using the gcd tool which is linked to in the doc above.

If you use DatastoreHelper.getDatastoreFromEnv(); to build your Datastore, you can tell it to connect to your local database by exporting the env variable DATASTORE_HOST:

export DATASTORE_HOST=http://localhost:8080