Skip to content

Commit

Permalink
Add switch for which health check to use
Browse files Browse the repository at this point in the history
Signed-off-by: Dylan Schultz <[email protected]>
  • Loading branch information
dylanschultzie committed Jul 5, 2024
1 parent 1c273d7 commit 6a73fd1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
11 changes: 11 additions & 0 deletions app/health_check_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from app.cosmos.cosmos import cosmos_health
from app.evm.ethereum import ethereum_health
from app.solana.solana import solana_health

switch = {
"45": ethereum_health,
"57": cosmos_health,
"17": cosmos_health,
"90": cosmos_health,
"99": solana_health,
}
16 changes: 3 additions & 13 deletions app/routes.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
# routes.py
from flask import Blueprint, request
from app.common import parse_request
from app.cosmos.cosmos import cosmos_health
from app.evm.ethereum import ethereum_health
from app.solana.solana import solana_health
from app.health_check_functions import switch

api = Blueprint("api", __name__)

health_check_functions = {
"45": ethereum_health,
"57": cosmos_health,
"17": cosmos_health,
"90": cosmos_health,
"99": solana_health,
}

@api.route("/health", methods=["GET"])
def health_check():
ip, port = parse_request(request)
rpc_type = port[:2]
health_check_function = health_check_functions.get(rpc_type)
rpc_type = port[-2:]
health_check_function = switch.get(rpc_type)

if health_check_function:
message, status = health_check_function(ip, port)
Expand Down

0 comments on commit 6a73fd1

Please sign in to comment.