使用微服务运行Google App Engine应用程序 [英] Run Google App Engine application with microservice

查看:136
本文介绍了使用微服务运行Google App Engine应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个庞大的monolith应用程序,现在是时候将一些模块分隔成微服务了!
我在Google文档中阅读了很多关于pub / sub和microservices的内容,但无法找到我的问题的答案:


  1. 如何app.yaml文件看起来像我的模块(微服务)?

  2. app.yaml如何为我的应用程序?(我的意思是,与微服务)
  3. 在哪里需要声明此模块 - 在应用程序app.yaml中还是在app.yaml中?

  4. 如何在应用程序和模块中使用单个数据存储?
  5. >

我的app.yaml现在看起来像:

  application:my-application 
version:1
runtime:python27
api_version:1
threadsafe:true

带有一些证书和库。



等待您的答案!

解决方案

单片应用程序实际上是一个具有单个模块/服务的应用程序(默认应用程序)。这个应用程序的 app.yaml 配置(就像你所显示的那样)实际上是默认模块的配置文件 - 没有per-app这样的配置。这些模块通过它们各自的< module> .yaml

  application:< app_identifier> 

在一个多模块应用程序中,每个模块都有自己的< module> .yaml 配置文件(名称不一定是 app.yaml ,如果模块代码共享相同,它实际上必须不同dir - 但我坚持推荐的目录结构 - 每个app子目录有一个模块)。



请参阅本Q& A(其中也包含一些示例):根据文件夹结构,Google App Engine应用中的默认服务/模块可以是非默认服务/模块吗?



默认模块名称可以/不应该设置。所有其他模块名称都在相应的< module> .yaml 文件中配置,如下所示:

  module:< module_name> 

同一应用程序中的所有模块共享相同的数据存储(因此同样的 index .html 文件)。注意,其他配置文件也是应用级配置,因此真正由所有模块共享(或者只是默认模块,即执行cron服务的模块,用于例如),我将它们按照应用程序顶层目录中的建议放置: cron.yaml dispatch.yaml queue.yaml


I have a one big monolith application, and now its time to separate some modules to micro services! I read a lot about pub/sub and microservices in Google docs, but can't find answers to my questions:

  1. How app.yaml file looks like for my module(microservice)?
  2. How app.yaml looks like for my app?(I mean, with microservice)
  3. Where I need to declare this module - in application app.yaml or in both app.yaml?
  4. How can I use single datastore with my app and my module?

My app.yaml now looks like:

application: my-application
version: 1
runtime: python27
api_version: 1
threadsafe: true

with some credentials and libs.

Waiting for your answers!

解决方案

A monolithic app is really an app with a single module/service (the default one). The app.yaml config for such app (like the one you shown) is really the default module's config file - there is no "per-app" such config. The modules are "tied" together into one specific app by this line in their respective <module>.yaml:

application: <app_identifier>

In a multi-module app each module has its own <module>.yaml config file (the name doesn't have to be app.yaml, it actually has to be different if the module code share the same dir - but I'd stick with the recommended directory structure - one module per app subdirectory).

See this Q&A (which also contains some examples): Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure?

The default module name can/should not be set. All other module names are configured in the respective <module>.yaml files, like this:

module: <module_name>

All modules in the same app share the same datastore (thus the same index.html file).

Note that other config files are also app-level configs, thus really shared by all modules (or just the default module, which is the one executing the cron service, for example), I'd place them as recommended in the app's top level dir: cron.yaml, dispatch.yaml, queue.yaml.

这篇关于使用微服务运行Google App Engine应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆