__init__.py 1.4 KB

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