__init__.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.apolloConnection = pyapollos.ApolloClient(
  16. app_id="LongArticlesMatchServer",
  17. config_server_url="https://apolloconfig-internal.piaoquantv.com/",
  18. timeout=10
  19. )
  20. self.articleVideos = "long_articles_match_videos"
  21. self.articleText = "long_articles_text"
  22. self.articleCrawlerVideos = "long_articles_crawler_videos"
  23. self.rootSourceIdTable = "long_articles_root_source_id"
  24. case "dev":
  25. self.apolloConnection = pyapollos.ApolloClient(
  26. app_id="LongArticlesMatchServer",
  27. config_server_url="https://devapolloconfig-internal.piaoquantv.com/",
  28. timeout=10
  29. )
  30. self.articleVideos = "long_articles_match_videos_dev"
  31. self.articleText = "long_articles_text_dev"
  32. self.articleCrawlerVideos = "long_articles_crawler_videos_dev"
  33. self.rootSourceIdTable = "long_articles_root_source_id_dev"
  34. case "pre":
  35. self.articleVideos = "long_articles_match_videos"
  36. self.articleText = "long_articles_text"
  37. self.articleCrawlerVideos = "long_articles_crawler_videos"
  38. self.rootSourceIdTable = "long_articles_root_source_id"
  39. self.apolloConnection = pyapollos.ApolloClient(
  40. app_id="LongArticlesMatchServer",
  41. config_server_url="http://preapolloconfig-internal.piaoquantv.com/",
  42. timeout=10
  43. )
  44. def getConfigValue(self, key):
  45. """
  46. 通过 key 获取配置的 Config
  47. :param key:
  48. :return:
  49. """
  50. response = self.apolloConnection.get_value(key)
  51. return response