Files

21 lines
601 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
心跳 MQTT 端点 — 仅上报,无需响应
通过 MQTT 主题 chongming/example/heartbeat 发送心跳,
Worker 返回 None,MQTT Bridge 不发布响应。
"""
import time
from chongming_worker import rpc_method
@rpc_method(
subject="example.heartbeat",
method="MQTT",
summary="Heartbeat ping via MQTT (no response)",
)
async def heartbeat(worker_id: str = "") -> None:
"""心跳上报 — 无返回值,MQTT Bridge 跳过响应发布"""
print(f"[Heartbeat] worker={worker_id} time={time.time()}")
return None # 显式返回 None,MQTT Bridge 不发布响应