Connection nodes speak of listener and sender, and of send_queue_size
mqtt and http take websocket's vocabulary: their Mode is LISTENER/SENDER, default names read mqtt_listener_… and http_listener_…, and mqtt's publish_queue_size is send_queue_size. No alias stays behind, so the flow store rewrites the old setting in every published and draft mqtt node when it opens, in the same migration as trigger → debounce. Every mqtt and http setting carries a one-line description for the editor, and the node-types reference uses one wording for direction and says that an http sender publishes a JSON object response on its outputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WgBfkm4rCmtd1T4vHWjEPx
This commit is contained in:
@@ -20,7 +20,7 @@ def test_http_senders_share_one_pooled_client():
|
||||
close_shared_client()
|
||||
|
||||
|
||||
def _publisher() -> MqttNode:
|
||||
def _sender() -> MqttNode:
|
||||
node = MqttNode(
|
||||
requires=[MessageSpec(name="setpoint", port="setpoint", dtype=DType.FLOAT)],
|
||||
params={"topic": {"setpoint": "heating/setpoint"}},
|
||||
@@ -29,27 +29,27 @@ def _publisher() -> MqttNode:
|
||||
return node
|
||||
|
||||
|
||||
def test_a_started_publisher_queues_instead_of_connecting():
|
||||
def test_a_started_sender_queues_instead_of_connecting():
|
||||
"""The handler runs on a worker thread; it must not block on the broker."""
|
||||
node = _publisher()
|
||||
node = _sender()
|
||||
|
||||
async def scenario() -> None:
|
||||
node._publish_queue = asyncio.Queue(maxsize=4)
|
||||
node._send_queue = asyncio.Queue(maxsize=4)
|
||||
node._loop = asyncio.get_running_loop()
|
||||
|
||||
await asyncio.to_thread(node._publisher_handler, {}, setpoint=21.0)
|
||||
await asyncio.to_thread(node._sender_handler, {}, setpoint=21.0)
|
||||
# call_soon_threadsafe lands on the next loop pass.
|
||||
await asyncio.sleep(0)
|
||||
|
||||
assert node._publish_queue.qsize() == 1
|
||||
assert node._publish_queue.get_nowait() == {"setpoint": 21.0}
|
||||
assert node._send_queue.qsize() == 1
|
||||
assert node._send_queue.get_nowait() == {"setpoint": 21.0}
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_a_full_publish_queue_drops_the_oldest():
|
||||
def test_a_full_send_queue_drops_the_oldest():
|
||||
"""A broker that cannot keep up must not grow the queue without bound."""
|
||||
node = _publisher()
|
||||
node = _sender()
|
||||
health: list[tuple[str, str | None]] = []
|
||||
node._on_health = lambda _n, status, detail: health.append((status, detail))
|
||||
|
||||
@@ -61,7 +61,7 @@ def test_a_full_publish_queue_drops_the_oldest():
|
||||
assert queue.qsize() == 2
|
||||
assert queue.get_nowait() == {"setpoint": 2.0}
|
||||
assert queue.get_nowait() == {"setpoint": 3.0}
|
||||
assert health == [("degraded", "publish queue full")]
|
||||
assert health == [("degraded", "send queue full")]
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
@@ -121,7 +121,7 @@ def test_the_configured_timeout_reaches_the_broker_client(monkeypatch):
|
||||
assert seen["timeout"] == 2.5
|
||||
|
||||
|
||||
def test_the_configured_backlog_reaches_the_publish_queue(monkeypatch):
|
||||
def test_the_configured_backlog_reaches_the_send_queue(monkeypatch):
|
||||
"""The depth is read when the queue is built, so it has to be per node."""
|
||||
import aiomqtt
|
||||
|
||||
@@ -139,14 +139,14 @@ def test_the_configured_backlog_reaches_the_publish_queue(monkeypatch):
|
||||
|
||||
node = MqttNode(
|
||||
requires=[MessageSpec(name="setpoint", port="setpoint", dtype=DType.FLOAT)],
|
||||
params={"topic": {"setpoint": "heating/setpoint"}, "publish_queue_size": 8},
|
||||
params={"topic": {"setpoint": "heating/setpoint"}, "send_queue_size": 8},
|
||||
)
|
||||
node.assign_flow("heating", "out")
|
||||
|
||||
async def scenario() -> int:
|
||||
await node.start_publisher()
|
||||
assert node._publish_queue is not None
|
||||
size = node._publish_queue.maxsize
|
||||
assert node._send_queue is not None
|
||||
size = node._send_queue.maxsize
|
||||
await node.stop_publisher()
|
||||
return size
|
||||
|
||||
|
||||
Reference in New Issue
Block a user