Skip to content

Commit

Permalink
Set default timeout of 5s in fibaro input (influxdata#5813)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson authored and idohalevi committed Sep 23, 2020
1 parent bcfaead commit 1a5c013
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions plugins/inputs/fibaro/fibaro.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import (
"fmt"
"net/http"
"strconv"
"time"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)

const defaultTimeout = 5 * time.Second

const sampleConfig = `
## Required Fibaro controller address/hostname.
## Note: at the time of writing this plugin, Fibaro only implemented http - no https available
Expand All @@ -28,13 +31,13 @@ const description = "Read devices value(s) from a Fibaro controller"

// Fibaro contains connection information
type Fibaro struct {
URL string
URL string `toml:"url"`

// HTTP Basic Auth Credentials
Username string
Password string
Username string `toml:"username"`
Password string `toml:"password"`

Timeout internal.Duration
Timeout internal.Duration `toml:"timeout"`

client *http.Client
}
Expand Down Expand Up @@ -212,6 +215,8 @@ func (f *Fibaro) Gather(acc telegraf.Accumulator) error {

func init() {
inputs.Add("fibaro", func() telegraf.Input {
return &Fibaro{}
return &Fibaro{
Timeout: internal.Duration{Duration: defaultTimeout},
}
})
}

0 comments on commit 1a5c013

Please sign in to comment.