__init__.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. case "copy1":
  45. self.articleVideos = "long_articles_match_videos_copy1"
  46. self.articleText = "long_articles_text_copy1"
  47. self.articleCrawlerVideos = "long_articles_crawler_videos_copy1"
  48. self.rootSourceIdTable = "long_articles_root_source_id_copy1"
  49. self.getOffVideos = "get_off_videos_copy1"
  50. self.apolloConnection = pyapollos.ApolloClient(
  51. app_id="LongArticlesMatchServer",
  52. config_server_url="http://preapolloconfig-internal.piaoquantv.com/",
  53. timeout=10
  54. )
  55. def getConfigValue(self, key):
  56. """
  57. 通过 key 获取配置的 Config
  58. :param key:
  59. :return:
  60. """
  61. response = self.apolloConnection.get_value(key)
  62. return response