generated from erangel1/generic-template
initial commit. phase 1 complete
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""
|
||||
Heartbeat task stubs — Phase 1 scaffolding.
|
||||
|
||||
Phase 2 implementations will:
|
||||
check_all_nodes — query Node.objects.filter(ip_address__isnull=False),
|
||||
dispatch check_single_node subtasks via Celery group()
|
||||
check_single_node — icmplib.ping() for ICMP, socket.connect_ex() for TCP,
|
||||
httpx.get() for HTTP; write HeartbeatLog record
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from config.celery import app
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@app.task(name="tasks.heartbeat.check_all_nodes", bind=True)
|
||||
def check_all_nodes(self) -> dict: # type: ignore[type-arg]
|
||||
"""Stub: ICMP/TCP liveness check for all nodes that have an IP address."""
|
||||
logger.debug("heartbeat.check_all_nodes: stub — Phase 2 not yet implemented")
|
||||
return {"status": "stub", "checked": 0}
|
||||
|
||||
|
||||
@app.task(name="tasks.heartbeat.check_single_node", bind=True, max_retries=2)
|
||||
def check_single_node(self, node_id: str, check_type: str = "icmp") -> dict: # type: ignore[type-arg]
|
||||
"""Stub: check a single node and write a HeartbeatLog record."""
|
||||
logger.debug("heartbeat.check_single_node: stub for node_id=%s", node_id)
|
||||
return {"status": "stub", "node_id": node_id, "check_type": check_type}
|
||||
Reference in New Issue
Block a user