__init__.py 2.6 KB

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