postgres healthcheck works
This commit is contained in:
parent
91c79357f8
commit
c38ce5cfe6
9 changed files with 203 additions and 8 deletions
|
|
@ -3,8 +3,9 @@ import pathlib
|
|||
from typing import Dict
|
||||
|
||||
from anaxi.file_persistence import read_yaml
|
||||
from anaxi.logging import get_anaxi_logger
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger = get_anaxi_logger(__name__)
|
||||
|
||||
|
||||
class CosmosDBDatabaseConfig:
|
||||
|
|
@ -38,3 +39,38 @@ class CosmosDBDatabaseConfig:
|
|||
raise e
|
||||
|
||||
return database_configs
|
||||
|
||||
|
||||
class PostgresDatabaseConfig:
|
||||
|
||||
config_root_key: str = "postgres-databases"
|
||||
|
||||
def __init__(self, host: str, port: int, dbname: str, user: str, password) -> None:
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.dbname = dbname
|
||||
self.user = user
|
||||
self.password = password
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, a_dict) -> "PostgresDatabaseConfig":
|
||||
return PostgresDatabaseConfig(**a_dict)
|
||||
|
||||
@classmethod
|
||||
def from_yaml(cls, path: pathlib.Path) -> Dict[str, "PostgresDatabaseConfig"]:
|
||||
yaml_contents = read_yaml(path)
|
||||
|
||||
postgres_contents = yaml_contents[PostgresDatabaseConfig.config_root_key]
|
||||
|
||||
try:
|
||||
database_configs = {
|
||||
db_name: PostgresDatabaseConfig.from_dict(db_config)
|
||||
for db_name, db_config in postgres_contents.items()
|
||||
}
|
||||
except KeyError as e:
|
||||
logger.error(
|
||||
"Error reading Postgres config yaml file. The file seems malformed. Review the example in the repository."
|
||||
)
|
||||
raise e
|
||||
|
||||
return database_configs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue