Skip to content
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

Set default timeout of 5s in fibaro input #5813

Merged
merged 1 commit into from
May 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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},
}
})
}