本文介绍了我是否需要在使用它的每个微服务(模块)中或仅在根应用程序中定义数据存储索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理具有多个微服务(模块)的应用程序.我在根应用程序(仅包含那些cfg文件,如datastore-indexes.xml和queue.xml等)中定义了数据存储区索引.我在控制台中看到了那些正在服务"的索引. [edit]所以我的错是我较早中断了查询,所以问题变化不大.在多模块appengine应用中,使用提及的cfg文件的最佳策略是什么?

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?

推荐答案

数据存储区索引配置是几种应用级配置之一,由应用中的所有服务/模块共享,并且可以可以独立于服务本身进行部署.实际上,建议先部署索引配置,让GAE将其配置为Serving状态(这可能需要一段时间,具体取决于需要建立索引的实体数),然后才部署需要这些索引的应用程序代码索引.

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.

对于在GAE上进行部署,只要索引配置是位于特定服务中还是位于应用程序的根目录中就没有关系,只要它是从该位置进行部署即可.

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.

但是,如果本地开发服务器在目录中没有索引配置的情况下无法运行特定服务,则可能会遇到麻烦-我怀疑这就是让您感到悲伤的原因.为了以DRY精神解决此问题,我的首选是在应用程序的根目录中拥有配置文件的主副本,并在每个服务目录中指向它的符号链接.

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.

事情变得更加复杂,因为Java GAE使用datastore-indexes.xml配置文件,而其他语言使用index.yaml文件,格式不同. Java也支持index.yaml文件,但是我不确定在开发服务器,IDE和/或其他本地开发工具中是否同样支持该文件.

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.

如果所有模块都基于Java,则应该没问题.但是,如果您使用多种语言,则可能必须尝试共享等效的index.yaml.

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.

如果这不起作用,并且您不得不使用两个文件,每个文件都链接到各自的语言服务目录中,则必须确保2个文件中的索引配置一致,否则可能会破坏某些文件服务.

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.

可能感兴趣的:

这篇关于我是否需要在使用它的每个微服务(模块)中或仅在根应用程序中定义数据存储索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 00:19