apollo.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. if env == "prod":
  14. self.apollo_connection = pyapollos.ApolloClient(
  15. app_id="LongArticlesMatchServer",
  16. config_server_url="https://apolloconfig-internal.piaoquantv.com/",
  17. timeout=10
  18. )
  19. elif env == "dev":
  20. self.apollo_connection = pyapollos.ApolloClient(
  21. app_id="LongArticlesMatchServer",
  22. config_server_url="https://devapolloconfig-internal.piaoquantv.com/",
  23. timeout=10
  24. )
  25. elif env == "pre":
  26. self.apollo_connection = pyapollos.ApolloClient(
  27. app_id="LongArticlesMatchServer",
  28. config_server_url="http://preapolloconfig-internal.piaoquantv.com/",
  29. timeout=10
  30. )
  31. def get_config_value(self, key):
  32. """
  33. 通过 key 获取配置的 Config
  34. :param key:
  35. :return:
  36. """
  37. response = self.apollo_connection.get_value(key)
  38. return response