Commit 049e876
authored
docs: a transport must preserve publish order, and why (#48)
MqttDeviceTransport says nothing about ordering, because neither transport the
SDK ships with can violate it: paho's own thread and asyncio_driver each pump one
client, so publishes reach the wire in the order they were made. A transport
written against the protocol directly need not, and one that starts a task per
publish() hands ordering to the scheduler.
That matters because ordering is a guarantee the SDK maintains on a producer's
behalf. A device's $description precedes the $state=ready that vouches for it,
and refresh_tree() publishes a device's own $state after the children it
announces -- which is what 0.18.1 fixed. Those are quality-of-implementation, not
protocol: a consumer must never depend on them, and doc/consuming-a-homie-tree.md
says so at length, since publish order does not survive retention. That is
precisely why the warning cannot live there. The consumer guide addresses the
other party, so it will never reach a transport author, who can silently drop a
guarantee the SDK spends effort meeting.
Also records the teardown consequence. A publish() that enqueues and returns is
entirely legitimate -- every return in the protocol is typed `object` because the
SDK discards them -- but Device.stop() publishes the final $state and returns
without flushing, so a queueing transport needs a drain point before its client
closes, or that message is lost behind it.
Raised by @cayossarian on #46, from building a natively-async transport where the
hazard is real rather than theoretical: it holds by luck under a fast broker and
breaks under a slow first publish.
Docs only; no source changed.1 parent 31f8376 commit 049e876
2 files changed
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
92 | 100 | | |
93 | 101 | | |
94 | 102 | | |
| |||
0 commit comments