Run Google App Engine application with microservic

2019-02-11 02:07发布

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!

1条回答
狗以群分
2楼-- · 2019-02-11 02:25

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.

查看更多
登录 后发表回答