Home  >  Article  >  Backend Development  >  How to Access AppEngine Datastore from a Standalone Go Binary in Development?

How to Access AppEngine Datastore from a Standalone Go Binary in Development?

Susan Sarandon
Susan SarandonOriginal
2024-10-25 02:40:30584browse

How to Access AppEngine Datastore from a Standalone Go Binary in Development?

Connecting to AppEngine Datastore in Development via Cloud Datastore API

Developing a distributed application that combines AppEngine and GCE can be challenging when it comes to accessing shared data. This question explores how to establish a connection between a standalone Go binary running on GCE and the embedded datastore in AppEngine's devappserver.

Currently, connecting to the AppEngine embedded datastore using the Google Cloud Datastore API (client library) is not feasible in the development environment. This is due to underlying architectural differences between the Java development server used by the Google Cloud Datastore tool (gcd.sh) and the Python development server used for Go development.

While direct HTTP calls are an alternative, they present their own set of challenges. The development server does not currently support the JSON API used by the Go client library.

Workaround:

As suggested by proppy, using the Cloud Datastore Protobuf HTTP API is a viable workaround. This involves compiling the Protobuf definition to Go code and sending POST HTTP requests directly to the datastore endpoint. While this method requires manually crafting requests, it provides a direct connection to the Cloud Datastore API, which may offer greater stability compared to the client library. Note that data sharing between the application and the in-development Cloud Datastore is not possible with this approach.

The above is the detailed content of How to Access AppEngine Datastore from a Standalone Go Binary in Development?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn