简体   繁体   English

如何在 Win 10 上本地测试 Gol App Engine 应用并使用 app.yaml

[英]How to Test Gol App Engine apps locally on Win 10 and use app.yaml

In Google's latest docs, they say to test Go 1.12+ apps locally, one should just go build.在 Google 的最新文档中,他们说要在本地测试 Go 1.12+ 应用程序,应该直接构建。

However, this doesn't take into account all the routing etc that would happen in the app engine utilizing the app.yaml config file.但是,这并未考虑使用 app.yaml 配置文件在应用引擎中发生的所有路由等。

I see that the dev_appserver.py is still included in the sdk.我看到 dev_appserver.py 仍然包含在 sdk 中。 But it doesn't seem to work in Windows 10.但它似乎不适用于 Windows 10。

How does one test their Go App Engine App locally with the app.yaml.如何使用 app.yaml 在本地测试他们的 Go App Engine 应用程序。 ie: as an actual emulated app engine app.即:作为实际模拟的应用程序引擎应用程序。

Thank you!谢谢!

On one hand, if your application consists of just the default service I would recommend to follow @cerise-limón comment suggestion.一方面,如果您的应用程序仅包含默认服务,我建议您遵循 @cerise-limón 评论建议。 In general, it is recommended for the routing logic of the application to be handled within the code.一般来说,建议在代码中处理应用程序的路由逻辑。 Although I'm not a Go programmer, for single service applications that use static_files and static_dir there shouldn't be any problems when testing the application locally.虽然我不是 Go 程序员,但对于使用 static_files 和 static_dir 的单服务应用程序,在本地测试应用程序时应该没有任何问题。 You might also deploy the new version without promoting traffic to it in order to test it as explained here .您也可以部署新版本而不增加流量,以便按照此处的说明对其进行测试。

On the other hand, if your application is distributed across multiple services and the routing is managed through the dispatch.yaml configuration file you might follow two approaches:另一方面,如果您的应用程序分布在多个服务中并且路由是通过dispatch.yaml配置文件管理的,您可能会采用两种方法:

  • Test each service locally one by one.在本地对每项服务进行一一测试。 This could be the way to go if each service has a single responsibility/functionality that could be tested in isolation from the other services.如果每个服务都有一个可以独立于其他服务进行测试的单一职责/功能,那么这可能是一种可行的方法。 In fact, with this kind of architecture the testing procedure would be more or less the same as for single service applications.事实上,对于这种架构,测试过程与单服务应用程序的测试过程或多或少是相同的。
  • Run all services locally at once and build your own routing layer.一次在本地运行所有服务并构建您自己的路由层。 This option would allow to test applications where services needs to reach one another in order to fulfill the requests made to them.此选项将允许测试服务需要相互访问的应用程序,以便满足向它们发出的请求。

Another approach that is widely used is to have a separate project for development purposes where you could just deploy the application and observe it's behavior in the App Engine environment.另一种广泛使用的方法是拥有一个单独的项目用于开发目的,您可以在其中部署应用程序并观察它在 App Engine 环境中的行为。 As for applications with highly coupled services it would be the easiest option.对于具有高度耦合服务的应用程序,这将是最简单的选择。 But it largely depends on your budget.但这在很大程度上取决于您的预算。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM