Closed MattBrittan closed 11 months ago
I prefer to make things exported as default, as you say with there being no mutex an the struct being copied it should be safe/fine to move to exported fields for the autopaho config.
@MattBrittan just wanted to let you know that you accidentally fixed a bug here; before setting will with empty payload (example use case: using will to clear retained message when client disconnect) did not set the will on connect (because condition was if len(cfg.willTopic) > 0 && len(cfg.willPayload) > 0 {
, now it works correctly.
Thanks :)
Autopaho.ClientConfig
originally contained exported fields only; PR #69 added a range of un-exported fields with setter functions e.g.and a few further examples have been added since (where the settings were similar to those already in place).
We really should standardise on one approach before releasing V1. I'm suggesting that all fields be exported because:
ClientConfig
does not contain aMutex
, and a copy is passed toNewConnection
, so races should not be an issue (it's clear that the config should not be changed after callingNewConnection
).paho.ClientConfig
At the same time I think it's worth renaming
BrokerUrls
toServerUrls
because the MQTT spec does not use the term Broker so its likely to be confusing to those new to the protocol. Again this can be non-breaking (NewConnection
can overwriteServerUrls
withBrokerUrls
if its empty).