__init__.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. """
  2. @author: luojunhui
  3. """
  4. import json
  5. import pyapollos
  6. class Config(object):
  7. """
  8. apolloConfig
  9. """
  10. def __init__(self, env="pre"):
  11. """
  12. :param env:
  13. """
  14. match env:
  15. case "prod":
  16. self.apolloConnection = pyapollos.ApolloClient(
  17. app_id="LongArticlesMatchServer",
  18. config_server_url="https://apolloconfig-internal.piaoquantv.com/",
  19. timeout=10
  20. )
  21. self.articleVideos = "long_articles_match_videos"
  22. self.articleText = "long_articles_text"
  23. self.articleCrawlerVideos = "long_articles_crawler_videos"
  24. self.rootSourceIdTable = "long_articles_root_source_id"
  25. case "dev":
  26. self.apolloConnection = pyapollos.ApolloClient(
  27. app_id="LongArticlesMatchServer",
  28. config_server_url="https://devapolloconfig-internal.piaoquantv.com/",
  29. timeout=10
  30. )
  31. self.articleVideos = "long_articles_match_videos_dev"
  32. self.articleText = "long_articles_text_dev"
  33. self.articleCrawlerVideos = "long_articles_crawler_videos_dev"
  34. self.rootSourceIdTable = "long_articles_root_source_id_dev"
  35. case "pre":
  36. self.articleVideos = "long_articles_match_videos"
  37. self.articleText = "long_articles_text"
  38. self.articleCrawlerVideos = "long_articles_crawler_videos"
  39. self.rootSourceIdTable = "long_articles_root_source_id"
  40. self.apolloConnection = pyapollos.ApolloClient(
  41. app_id="LongArticlesMatchServer",
  42. config_server_url="http://preapolloconfig-internal.piaoquantv.com/",
  43. timeout=10
  44. )
  45. def getConfigValue(self, key):
  46. """
  47. 通过 key 获取配置的 Config
  48. :param key:
  49. :return:
  50. """
  51. response = self.apolloConnection.get_value(key)
  52. return response