influxdb/services/subscriber/config.go

36 lines
668 B
Go
Raw Normal View History

package subscriber
2016-05-17 19:36:03 +00:00
import (
"errors"
"time"
"github.com/influxdata/influxdb/toml"
)
const (
DefaultHTTPTimeout = 30 * time.Second
)
// Config represents a configuration of the subscriber service.
type Config struct {
// Whether to enable to Subscriber service
Enabled bool `toml:"enabled"`
2016-05-17 19:36:03 +00:00
HTTPTimeout toml.Duration `toml:"http-timeout"`
}
// NewConfig returns a new instance of a subscriber config.
func NewConfig() Config {
2016-05-17 19:36:03 +00:00
return Config{
Enabled: true,
HTTPTimeout: toml.Duration(DefaultHTTPTimeout),
}
}
func (c Config) Validate() error {
if c.HTTPTimeout <= 0 {
return errors.New("http-timeout must be greater than 0")
}
return nil
}