-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MF-28 - enabled messages paho persistence #27
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,11 +162,18 @@ func (e *exporter) mqttConnect(conf config.Config, logger logger.Logger) (mqtt.C | |
opts := mqtt.NewClientOptions(). | ||
AddBroker(conf.MQTT.Host). | ||
SetClientID(e.id). | ||
SetCleanSession(true). | ||
SetCleanSession(conf.MQTT.CleanSession). | ||
SetAutoReconnect(true). | ||
SetOnConnectHandler(e.conn). | ||
SetConnectionLostHandler(e.lost) | ||
|
||
if conf.MQTT.Persist { | ||
store := mqtt.NewFileStore(conf.MQTT.PersistDir) | ||
opts.SetStore(store) | ||
//disable clean session because paho deletes stored messages when restarts | ||
opts.SetCleanSession(false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we want to make this configurable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if user set persistent = true but clean session = true, when service restarts messages are lost. I can change implementation and make the settings completely independent, but in that case user have to manually set clean_session = false when he wants to persist messages in fs |
||
} | ||
|
||
if conf.MQTT.Username != "" && conf.MQTT.Password != "" { | ||
opts.SetUsername(conf.MQTT.Username) | ||
opts.SetPassword(conf.MQTT.Password) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments start with the capital letter. Also, add one space after
//
.