apollo.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """
  2. @author: luojunhui
  3. """
  4. import pyapollos
  5. class Config(object):
  6. """
  7. apolloConfig
  8. """
  9. def __init__(self, env="pre"):
  10. """
  11. :param env:
  12. """
  13. match env:
  14. case "prod":
  15. self.apollo_connection = pyapollos.ApolloClient(
  16. app_id="LongArticlesMatchServer",
  17. config_server_url="https://apolloconfig-internal.piaoquantv.com/",
  18. timeout=10
  19. )
  20. case "dev":
  21. self.apollo_connection = pyapollos.ApolloClient(
  22. app_id="LongArticlesMatchServer",
  23. config_server_url="https://devapolloconfig-internal.piaoquantv.com/",
  24. timeout=10
  25. )
  26. case "pre":
  27. self.apollo_connection = pyapollos.ApolloClient(
  28. app_id="LongArticlesMatchServer",
  29. config_server_url="http://preapolloconfig-internal.piaoquantv.com/",
  30. timeout=10
  31. )
  32. def get_config_value(self, key):
  33. """
  34. 通过 key 获取配置的 Config
  35. :param key:
  36. :return:
  37. """
  38. response = self.apollo_connection.get_value(key)
  39. return response