Repository navigation
send mqtt disconnect on peer shutdown, derive keepalive from lease, add optional presence to mqp2p - #38
Merged
Conversation
…dd optional presence to mqp2p
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Peer::shutdownsends MQTT DISCONNECT after deregistering, and dropping aPeerinside a Tokio runtime does too. Before, the mqtt5 client outlived the peer and kept reconnecting undermqp2p-<name>, so a peer that went offline and back online fought its old client for the session.PeerConfig::with_keepalive_secs, defaulting to a third of the lease (5 s for the default 15 s lease) instead of mqtt5's 60 s. The broker drops a silent client after 1.5 keepalives, checked once per keepalive, so a dead link is noticed in 7.5 to 12.5 s instead of the ~115 s measured in the c2-fusion harness.PeerConfig::with_presence(opt-in): follow MQDB's$DB/_presence/#and skip peers whose MQTT client has disconnected until they reconnect. Out-of-order events are ignored byts, onlymqp2p-client ids are tracked, and the table is capped at 4096 entries. The lease remains the backstop.mqp2p/responses/#, since MQDB 0.8.33 answers only on topics the requester may publish to).Tests: shutdown and drop each send a clean DISCONNECT (presence event with
unexpected: false), and presence hides a departed peer within 5 s despite a 60 s lease and shows it again on return. All three fail without the disconnect; the presence test also fails withoutwith_presence. Unit tests cover presence ordering, the cap, the client-id filter and the keepalive default. Workspace: 240 passed, 0 failed. The mqp2p integration tests need an installedmqdbbinary and are not run in CI; they passed 5 times in a row locally against mqdb 0.8.51.