def genericLazyConfig(db, dbKey, serviceName, clusterName):
if db.exists(dbKey):
rawConfig = db.get(dbKey)
try:
config = json.loads(rawConfig)
except ValueError as e:
raise ValueError("Failed to decode SQL DB config %s: %s" % (config, e))
try:
host = config["host"]
database = config["database"]
user = config["user"]
password = config["password"]
except KeyError as e:
raise KeyError("Missing a required SQL config key in config %s: %s" % (config, e))
return host, database, user, password
else:
raise RuntimeError("No SQL connection configures for "
"service %s of cluster %s" % (
serviceName, clusterName))
评论列表
文章目录