0

I have an App Engine application that has multiple independent modules.

When deployed, these modules become available at http://<module>.<app_id>.appspot.com, and when testing locally with dev_appserver.py mod1.yaml mod2.yaml --port-9000, then mod1 runs in http://localhost:9000 and mod2 runs in http://localhost:9001. All the modules are running on the same project. So far so good.

Let's assume mod1 needs to talk to mod2. Is there a way I can get a url for mod2 within mod1, dynamically?

# In mod1's code
import google.some.magic
url_for_mod2 = magic.get_url_for_module('mod2') # http://localhost:9001 or http://mod2.id.appspot.com
ButterDog
  • 5,115
  • 6
  • 43
  • 61

2 Answers2

1

It is possible to build cross-module urls that work on both GAE and on the development server using the modules.get_hostname() API. You can find an example in this answer: https://stackoverflow.com/a/31145647/4495081

Community
  • 1
  • 1
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
0

As long as I know it is not possible. As you have 2 services, and maybe more in the future, it seems you are using a distributed microservices architecture and therefore you need to register your services for them to know where the other service is. For that I recommend etcd it is really pretty easy to use. A nice fellow also written a python-client for it!

JeanPaulDepraz
  • 625
  • 7
  • 12