__init__.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. """
  2. @author: luojunhui
  3. """
  4. import pyapollos
  5. class apolloConfig(object):
  6. """
  7. apolloConfig
  8. """
  9. def __init__(self, env="pre"):
  10. """
  11. :param env:
  12. """
  13. self.apollo_connection = pyapollos.ApolloClient(
  14. app_id="LongArticlesJob",
  15. config_server_url="https://preapolloconfig-internal.piaoquantv.com/",
  16. timeout=10
  17. )
  18. match env:
  19. case "prod":
  20. self.apollo_connection = pyapollos.ApolloClient(
  21. app_id="LongArticlesJob",
  22. config_server_url="https://apolloconfig-internal.piaoquantv.com/",
  23. timeout=10
  24. )
  25. case "dev":
  26. self.apollo_connection = pyapollos.ApolloClient(
  27. app_id="LongArticlesJob",
  28. config_server_url="https://devapolloconfig-internal.piaoquantv.com/",
  29. timeout=10
  30. )
  31. case "pre":
  32. self.apollo_connection = pyapollos.ApolloClient(
  33. app_id="LongArticlesJob",
  34. config_server_url="http://preapolloconfig-internal.piaoquantv.com/",
  35. timeout=10
  36. )
  37. def getConfigValue(self, key):
  38. """
  39. 通过 key 获取配置的 Config
  40. :param key:
  41. :return:
  42. """
  43. response = self.apollo_connection.get_value(key)
  44. return response
  45. # aigc后台数据库连接配置
  46. denet_config = {
  47. 'host': 'rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com',
  48. 'port': 3306,
  49. 'user': 'crawler_admin',
  50. 'password': 'cyber#crawler_2023',
  51. 'db': 'aigc-admin-prod',
  52. 'charset': 'utf8mb4'
  53. }
  54. # 长文数据库连接配置
  55. long_articles_config = {
  56. 'host': 'rm-bp14529nwwcw75yr1ko.mysql.rds.aliyuncs.com',
  57. 'port': 3306,
  58. 'user': 'changwen_admin',
  59. 'password': 'changwen@123456',
  60. 'db': 'long_articles',
  61. 'charset': 'utf8mb4'
  62. }
  63. # 票圈爬虫库数据库配置
  64. piaoquan_crawler_config = {
  65. 'host': 'rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com',
  66. 'port': 3306,
  67. 'user': 'crawler',
  68. 'password': 'crawler123456@',
  69. 'db': 'piaoquan-crawler',
  70. 'charset': 'utf8mb4'
  71. }