move Server code into more services and use them into blueprints or server

This commit is contained in:
2026-04-06 04:20:07 +02:00
parent 30eb17bb83
commit 98be2fe6fe
8 changed files with 373 additions and 302 deletions
+9 -9
View File
@@ -4,27 +4,27 @@ from typing import TYPE_CHECKING
if TYPE_CHECKING:
from server.Server import Server
def create_metrics_blueprint(server:"Server") -> Blueprint:
blueprint = Blueprint("metrics", __name__)
def create_metrics_blueprint(server:'Server') -> Blueprint:
blueprint = Blueprint('metrics', __name__)
@blueprint.get("/metrics")
@blueprint.get('/metrics')
async def metrics():
snapshot = await server.metrics_collector.build_snapshot(
server.game_last_seen_unix,
server.game_move_counts,
server.game_runtime.game_last_seen_unix,
server.game_runtime.game_move_counts,
)
return jsonify(snapshot)
@blueprint.get("/metrics/prometheus")
@blueprint.get('/metrics/prometheus')
async def metrics_prometheus():
snapshot = await server.metrics_collector.build_snapshot(
server.game_last_seen_unix,
server.game_move_counts,
server.game_runtime.game_last_seen_unix,
server.game_runtime.game_move_counts,
)
return (
server.metrics_collector.build_prometheus_metrics(snapshot),
200,
{"Content-Type": "text/plain; version=0.0.4; charset=utf-8"},
{'Content-Type': 'text/plain; version=0.0.4; charset=utf-8'},
)
return blueprint