apollo_api.py 798 B

123456789101112131415161718192021222324
  1. import pyapollos
  2. class ApolloApi:
  3. def __init__(self, app_id="LongArticlesJob", env="pre"):
  4. match env:
  5. case "pre":
  6. config_server_url = 'http://preapolloconfig-internal.piaoquantv.com/'
  7. case "dev":
  8. config_server_url = 'https://devapolloconfig-internal.piaoquantv.com/'
  9. case "prod":
  10. config_server_url = 'https://apolloconfig-internal.piaoquantv.com/'
  11. case _:
  12. raise ValueError("env must be 'pre' or 'dev' or 'prod'")
  13. self.apollo_connection = pyapollos.ApolloClient(
  14. app_id=app_id,
  15. config_server_url=config_server_url,
  16. timeout=10
  17. )
  18. def get_config_value(self, key):
  19. return self.apollo_connection.get_value(key)