英文:
Request microservice to another microservice
问题
我正在将我的项目从Compute Engine迁移到App Engine,在Compute Engine中,我定义了每个服务将使用的端口。因此,在彼此通信时,我所做的是通过简单的localhost:端口号来调用它们,一切都很顺利;直到我在App Engine中也要做同样的事情,结果我无法识别我部署的每个服务的一种类似的本地URL。
我认为定义公共URL(
英文:
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't forget: gcloud app deploy dispatch.yaml after changes !!!
- url: "*/urls/that/need/more/RAM/" # note wildcard capability
service: service_1
- url: "urls/that/need/more/speed/*" # note wildcard capability
service: service_2
- url: "service_1.app_name.appspot.com/*" # this should match cron calls to service_1 target
service: service_1
- url: "*/.*"
service: default
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论