Skip to content

Commit

Permalink
fix: remove dead code and actually set metric
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenschneider committed Jul 4, 2023
1 parent 59fe078 commit 1b08613
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
1 change: 1 addition & 0 deletions cmd/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func main() {
if err := env.Parse(config); err != nil {
log.Fatal().Msgf("%+v\n", err)
}
metrics.MqttBrokersConfiguredTotal.Set(float64(len(config.Brokers)))

// supply once flag value
config.Once = *once
Expand Down
1 change: 1 addition & 0 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func RunServer(configPath string) {
if err != nil {
log.Fatal().Msgf("Config validation failed: %v", err)
}
metrics.MqttBrokersConfiguredTotal.Set(float64(len(config.Brokers)))
conf.PrintFields(config, conf.SensitiveFields...)

var notificationImpl notification.Notification
Expand Down
17 changes: 0 additions & 17 deletions conf/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package conf
import (
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"github.com/rs/zerolog/log"
"github.com/soerenschneider/dyndns/internal/metrics"
"os"
)

Expand Down Expand Up @@ -67,18 +65,3 @@ func (conf MqttConfig) String() string {

return base
}

func (conf *MqttConfig) Validate() error {
metrics.MqttBrokersConfiguredTotal.Set(float64(len(conf.Brokers)))
if len(conf.Brokers) == 0 {
return errors.New("no brokers configured")
}

for _, broker := range conf.Brokers {
if !IsValidUrl(broker) {
return fmt.Errorf("no valid host given: %s", broker)
}
}

return nil
}

0 comments on commit 1b08613

Please sign in to comment.