[#2] master模块开发测试
This commit is contained in:
24
src/master/app/routes.py
Normal file
24
src/master/app/routes.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from flask import Flask, jsonify
|
||||
|
||||
from .config import AppConfig
|
||||
from .nodes_api import create_nodes_blueprint
|
||||
from .scheduler import StatusScheduler
|
||||
from .storage import Storage
|
||||
|
||||
|
||||
def register_routes(app: Flask, storage: Storage, scheduler: StatusScheduler, config: AppConfig) -> None:
|
||||
app.register_blueprint(create_nodes_blueprint(storage, scheduler), url_prefix="/api/v1/master")
|
||||
|
||||
@app.get("/healthz")
|
||||
def healthz():
|
||||
return jsonify({"status": "ok"})
|
||||
|
||||
@app.get("/readyz")
|
||||
def readyz():
|
||||
try:
|
||||
storage.list_nodes() # simple readiness probe
|
||||
except Exception as exc: # pragma: no cover - defensive
|
||||
return jsonify({"status": "error", "error": str(exc)}), 500
|
||||
return jsonify({"status": "ok"})
|
||||
Reference in New Issue
Block a user