请求一个微服务到另一个微服务

huangapple go评论57阅读模式
英文:

Request microservice to another microservice

问题

我正在将我的项目从Compute Engine迁移到App Engine,在Compute Engine中,我定义了每个服务将使用的端口。因此,在彼此通信时,我所做的是通过简单的localhost:端口号来调用它们,一切都很顺利;直到我在App Engine中也要做同样的事情,结果我无法识别我部署的每个服务的一种类似的本地URL。

我认为定义公共URL(..appspot.com),这是在部署每个服务时生成的,可能是一个不好的主意,因为会产生网络流量。

英文:

I am migrating my project from ComputeEngine to AppEngine, in ComputeEngine I defined the port with which each service would work. So when communicating with each other, what I did was call them with a simple localhost: port and everything was happiness; until I have to do the same in AppEngine, it turns out that I cannot identify a kind of local url of each service that I have deployed.

I think that defining the public url (<service>. <project-id> .appspot.com) that is generated when deploying each service would be a bad idea due to the network traffic that would be generated.

答案1

得分: 2

dispatch: # 不要忘记:在更改后部署 dispatch.yaml 文件,使用 gcloud app deploy dispatch.yaml !!!

- url: "*/urls/that/need/more/RAM/"  # 注意通配符能力
  service: service_1

- url: "urls/that/need/more/speed/*"  # 注意通配符能力
  service: service_2

- url: "service_1.app_name.appspot.com/*" # 这应该与调用 service_1 目标的定时任务匹配
  service: service_1

- url: "*/.*"
  service: default
英文:

With a dispatch.yaml, you can determine which service serves each url:

dispatch: # don&#39;t forget:  gcloud app deploy dispatch.yaml after changes !!!

- url: &quot;*/urls/that/need/more/RAM/&quot;  # note wildcard capability
  service: service_1
  
- url: &quot;urls/that/need/more/speed/*&quot;  # note wildcard capability
  service: service_2
  
- url: &quot;service_1.app_name.appspot.com/*&quot; # this should match cron calls to service_1 target
  service: service_1
  
- url: &quot;*/.*&quot;
  service: default

huangapple
  • 本文由 发表于 2020年9月3日 13:18:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/63717289.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定