2015-10-08 16:45:23 +00:00
|
|
|
package subscriber
|
|
|
|
|
2016-05-17 19:36:03 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/influxdata/influxdb/toml"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
DefaultHTTPTimeout = 30 * time.Second
|
|
|
|
)
|
|
|
|
|
2015-11-18 09:32:39 +00:00
|
|
|
// Config represents a configuration of the subscriber service.
|
2015-10-08 16:45:23 +00:00
|
|
|
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"`
|
2015-10-08 16:45:23 +00:00
|
|
|
}
|
|
|
|
|
2015-11-18 09:32:39 +00:00
|
|
|
// NewConfig returns a new instance of a subscriber config.
|
2015-10-08 16:45:23 +00:00
|
|
|
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
|
2015-10-08 16:45:23 +00:00
|
|
|
}
|