add healthcheck cli command
This commit is contained in:
parent
6e8b0a1c58
commit
029514d80b
2 changed files with 22 additions and 8 deletions
|
|
@ -10,7 +10,7 @@ from dotenv import load_dotenv
|
||||||
|
|
||||||
from xexe.constants import PATHS, RATES_SOURCES
|
from xexe.constants import PATHS, RATES_SOURCES
|
||||||
from xexe.inputs_handling import handle_get_rates_inputs
|
from xexe.inputs_handling import handle_get_rates_inputs
|
||||||
from xexe.processes import run_get_rates, run_xe_healthcheck
|
from xexe.processes import run_dwh_healthcheck, run_get_rates, run_xe_healthcheck
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.DEBUG,
|
level=logging.DEBUG,
|
||||||
|
|
@ -51,6 +51,13 @@ def xe_healthcheck():
|
||||||
logger.info("Healthcheck attempt finished.")
|
logger.info("Healthcheck attempt finished.")
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
def dwh_healthcheck():
|
||||||
|
logger.info("Running healthcheck against dwh API.")
|
||||||
|
run_dwh_healthcheck()
|
||||||
|
logger.info("Healthcheck attempt finished.")
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option(
|
@click.option(
|
||||||
"--start-date",
|
"--start-date",
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,8 @@ from xecd_rates_client import XecdClient
|
||||||
|
|
||||||
from xexe.constants import RATES_SOURCES
|
from xexe.constants import RATES_SOURCES
|
||||||
from xexe.exchange_rates import ExchangeRates, add_equal_rates, add_inverse_rates
|
from xexe.exchange_rates import ExchangeRates, add_equal_rates, add_inverse_rates
|
||||||
from xexe.rate_fetching import (
|
from xexe.rate_fetching import build_rate_fetcher
|
||||||
MockRateFetcher,
|
from xexe.rate_writing import build_rate_writer
|
||||||
RateFetcher,
|
|
||||||
XERateFetcher,
|
|
||||||
build_rate_fetcher,
|
|
||||||
)
|
|
||||||
from xexe.rate_writing import CSVRateWriter, RateWriter, build_rate_writer
|
|
||||||
from xexe.utils import DateRange, generate_currency_and_dates_combinations
|
from xexe.utils import DateRange, generate_currency_and_dates_combinations
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
@ -58,6 +53,18 @@ def run_xe_healthcheck() -> None:
|
||||||
logger.info(account_info_response)
|
logger.info(account_info_response)
|
||||||
|
|
||||||
|
|
||||||
|
def run_dwh_healthcheck():
|
||||||
|
"""
|
||||||
|
Try to connect to the DWH and perform some pre-requisites checks.
|
||||||
|
|
||||||
|
If this doesn't pass, don't even try to fetch rates because you won't be
|
||||||
|
able to write them into the DWH.
|
||||||
|
"""
|
||||||
|
logger.info("Connecting to DWH and looking for schema.")
|
||||||
|
dwh_rate_writer = build_rate_writer(output="dwh")
|
||||||
|
logger.info("DWH reached successfully.")
|
||||||
|
|
||||||
|
|
||||||
def run_get_rates(
|
def run_get_rates(
|
||||||
date_range: DateRange,
|
date_range: DateRange,
|
||||||
currencies: List[Currency],
|
currencies: List[Currency],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue