Do I need to define datastore-indexes in every mic

2019-02-27 04:56发布

I work on an application with several microservices (modules). I defined datastore indexes in root application (which is containing just only those cfg files like datastore-indexes.xml and queue.xml etc). I see those indexes "serving" in console. [edit] so my fault i broken query earlier so question changes little. What is best strategy with mentioned cfg files in multi-module appengine app?

1条回答
等我变得足够好
2楼-- · 2019-02-27 05:18

The datastore index configuration is one of the several app-level configurations, shared by all services/modules in the app and which can be deployed independently from the services themselves. In fact it's recommended to first deploy the indexes configuration, let GAE get those in Serving state (which may take a good while, depending on the number of entities that need to be indexed) and only after that deploy the app code needing those indexes.

For deployment on GAE purpose it doesn't really matter if the index configuration is located in a particular service or in the root of the application, as long as it's deployed from that location.

However the local development server may have trouble running a particular service without the index configuration in that server's directory - I suspect that's what causes you grief. To address this in the DRY spirit my preference is to have a master copy of the configuration file in the app root directory and symlinks pointing to it into each of the services directories.

Things get a bit more complicated because the Java GAE uses the datastore-indexes.xml configuration file while the other languages use the index.yaml file, with different formats. Java also supports the index.yaml file, but I'm not certain if that's equally well supported in the development server, IDEs and/or other local development tools.

If all your modules are Java-based you should be OK. But if you have a mix of languages you'll probably have to try to share an index.yaml equivalent.

If that doesn't work and you're forced to use both files, each symlinked into the respective language service dirs, you'll have to make sure the index configs in the 2 files are consistent, otherwise you risk breaking some of the services.

Potentially of interest: Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure?

查看更多
登录 后发表回答