Skip to content

Commit

Permalink
Remove default mqtt timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Apr 19, 2020
1 parent bb5ac6a commit fe8523d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions provider/config.go
Expand Up @@ -9,7 +9,6 @@ import (

const (
execTimeout = 5 * time.Second
mqttTimeout = 5 * time.Second
)

// Config is the general provider config
Expand Down Expand Up @@ -43,9 +42,6 @@ func mqttFromConfig(log *api.Logger, other map[string]interface{}) mqttConfig {
var pc mqttConfig
api.DecodeOther(log, other, &pc)

if pc.Timeout == 0 {
pc.Timeout = mqttTimeout
}
if pc.Multiplier == 0 {
pc.Multiplier = 1
}
Expand Down
8 changes: 4 additions & 4 deletions provider/mqtt.go
Expand Up @@ -247,7 +247,7 @@ func (h *msgHandler) floatGetter() (float64, error) {
h.mux.Lock()
defer h.mux.Unlock()

if elapsed := time.Since(h.updated); elapsed > h.timeout {
if elapsed := time.Since(h.updated); h.timeout != 0 && elapsed > h.timeout {
return 0, fmt.Errorf("%s outdated: %v", h.topic, elapsed.Truncate(time.Second))
}

Expand All @@ -264,7 +264,7 @@ func (h *msgHandler) intGetter() (int64, error) {
h.mux.Lock()
defer h.mux.Unlock()

if elapsed := time.Since(h.updated); elapsed > h.timeout {
if elapsed := time.Since(h.updated); h.timeout != 0 && elapsed > h.timeout {
return 0, fmt.Errorf("%s outdated: %v", h.topic, elapsed.Truncate(time.Second))
}

Expand All @@ -281,7 +281,7 @@ func (h *msgHandler) stringGetter() (string, error) {
h.mux.Lock()
defer h.mux.Unlock()

if elapsed := time.Since(h.updated); elapsed > h.timeout {
if elapsed := time.Since(h.updated); h.timeout != 0 && elapsed > h.timeout {
return "", fmt.Errorf("%s outdated: %v", h.topic, elapsed.Truncate(time.Second))
}

Expand All @@ -293,7 +293,7 @@ func (h *msgHandler) boolGetter() (bool, error) {
h.mux.Lock()
defer h.mux.Unlock()

if elapsed := time.Since(h.updated); elapsed > h.timeout {
if elapsed := time.Since(h.updated); h.timeout != 0 && elapsed > h.timeout {
return false, fmt.Errorf("%s outdated: %v", h.topic, elapsed.Truncate(time.Second))
}

Expand Down

0 comments on commit fe8523d

Please sign in to comment.