feat(rumqttd): expose retain flag on local LinkTx publish#1050
Open
podarok wants to merge 1 commit into
Open
Conversation
`local::LinkTx::publish` and `try_publish` hardcode `retain: false`, which prevents in-process callers from seeding the retained store with snapshot-class topics. Embedded-broker setups that want to serve a state snapshot to late subscribers on first SUBSCRIBE currently have to spin up a loopback rumqttc client to publish with retain over the wire, or wait for the next live publish. Add `publish_with_retain` and `try_publish_with_retain` that take an explicit retain flag. Existing `publish` / `try_publish` keep the previous behaviour and now delegate, so the change is fully backwards-compatible.
Contributor
|
@giridher-art Can you review this? |
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.
Type of change
New feature (non-breaking change which adds functionality).
What this fixes
local::LinkTx::publishandtry_publishhardcoderetain: false(rumqttd/src/link/local.rs:223,242), which prevents an in-process publisher from seeding the broker's retained store. Anyone embeddingrumqttdand wanting to serve a snapshot to late subscribers on first SUBSCRIBE has had to either:rumqttcclient and publish-with-retain over the wire (extra dependency, extra connect/CONNACK race window), orWhat this PR does
Add two thin wrappers that take an explicit retain flag:
The existing
publishandtry_publishkeep their previous behaviour (retain: false) and now delegate, so the change is fully backwards-compatible.Use case
ec-ui-light(a Tauri desktop app that ships an embeddedrumqttdto replay captured Victron MQTT fixtures) needs to seed the retained store with a small set of dashboard-critical topics (system/0/Serial,system/0/Dc/Battery/Soc,system/0/Ac/Grid/...) before the WebView's MQTT client subscribes. Doing this through a loopbackrumqttcclient raced the WebView's first SUBSCRIBE; callingpublish_with_retaindirectly on a freshly-builtLinkTxpopulates the retained store synchronously and the race goes away.Checklist
cargo fmt[Unreleased]