[英]How to connect to the local google cloud Datastore db?
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 . 我有GAE应用程序,它可以在Google Cloud Datastore中创建一些数据并将一些二进制文件存储到Google Cloud Storage中-我们将其称为WebApp应用程序 。 Now I have a different application running on the Google compute engine.
现在,我在Google计算引擎上运行了另一个应用程序。 Let's call the application ComputeApp .
让我们将应用程序称为ComputeApp 。
The ComputeApp is a backend process which is processing data created by the WebApp . ComputeApp是一个后端过程,正在处理由WebApp创建的数据。 I asked here in this question previously which API can I use to communicate with Datastore from the ComputeApp .
我之前在此问题中曾问过,我可以使用哪个API与ComputeApp的数据存储区通信。 As suggested by @proppy, I implemented the Datastore communication using of the Google Cloud Datastore API .
按照@proppy的建议,我使用Google Cloud Datastore API实现了数据存储通信。
Everything works fine as far as I'm communicating with the Datastore in the Google cloud. 就我与Google云中的数据存储进行通信而言,一切正常。 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. 现在,我需要在开发PC上本地运行ComputeApp,以便获取由本地WebApp创建并存储到本地调试数据存储区中的数据。 I need it because I want to have a testing environment so I can debug may GAE app locally.
我需要它是因为我想要一个测试环境,以便可以在本地调试可能的GAE应用程序。
How should I modify my ComputeApp code to force it to connect to my local debug Datastore instead of connect to the Google cloud? 如何修改ComputeApp代码以强制其连接到本地调试数据存储区,而不是连接到Google云?
I googled a lot and didn't find any advice nor example. 我在Google上搜索了很多,没有找到任何建议或示例。 Only possible way I found that I should rewrite my code completely and use a different API to do that.
我发现的唯一可能的方法是,我应该完全重写我的代码,并使用其他API来执行此操作。 Such is Datastore Remote API.
这就是数据存储区远程API。 Is this really only way?
这真的是唯一的方法吗? Should I really rewrite whole ComputeApp to connect to the local DB?
我是否应该真正重写整个ComputeApp以连接到本地数据库? Really?
真?
I hope that I just overlooked something important and It's not true... 我希望我只是忽略了一些重要的事情,这是不对的...
Google Cloud Datastore has a local development server that you can use: https://developers.google.com/datastore/docs/tools/devserver Google Cloud Datastore拥有您可以使用的本地开发服务器: 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. 您可以使用上面doc中链接到的gcd工具创建并启动本地数据存储。
If you use DatastoreHelper.getDatastoreFromEnv();
如果使用
DatastoreHelper.getDatastoreFromEnv();
to build your Datastore, you can tell it to connect to your local database by exporting the env variable DATASTORE_HOST
: 要构建数据存储区,您可以通过导出环境变量
DATASTORE_HOST
告诉它连接到本地数据库:
export DATASTORE_HOST=http://localhost:8080
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.