__init__.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.apollo_connection = pyapollos.ApolloClient(
  16. app_id="LongArticlesMatchServer",
  17. config_server_url="https://apolloconfig-internal.piaoquantv.com/",
  18. timeout=10
  19. )
  20. self.article_match_video_table = "long_articles_match_videos"
  21. self.article_text_table = "long_articles_text"
  22. self.article_crawler_video_table = "long_articles_crawler_videos"
  23. self.root_source_id_table = "long_articles_root_source_id"
  24. self.get_off_video_table = "get_off_video"
  25. case "dev":
  26. self.apollo_connection = pyapollos.ApolloClient(
  27. app_id="LongArticlesMatchServer",
  28. config_server_url="https://devapolloconfig-internal.piaoquantv.com/",
  29. timeout=10
  30. )
  31. self.article_match_video_table = "long_articles_match_videos_copy1"
  32. self.article_text_table = "long_articles_text_copy1"
  33. self.article_crawler_video_table = "long_articles_crawler_videos_copy1"
  34. self.root_source_id_table = "long_articles_root_source_id_copy1"
  35. self.get_off_video_table = "get_off_video_copy1"
  36. case "pre":
  37. self.apollo_connection = pyapollos.ApolloClient(
  38. app_id="LongArticlesMatchServer",
  39. config_server_url="http://preapolloconfig-internal.piaoquantv.com/",
  40. timeout=10
  41. )
  42. self.article_match_video_table = "long_articles_match_videos"
  43. self.article_text_table = "long_articles_text"
  44. self.article_crawler_video_table = "long_articles_crawler_videos"
  45. self.root_source_id_table = "long_articles_root_source_id"
  46. self.get_off_video_table = "get_off_video"
  47. def get_config_value(self, key):
  48. """
  49. 通过 key 获取配置的 Config
  50. :param key:
  51. :return:
  52. """
  53. response = self.apollo_connection.get_value(key)
  54. return response