[#493] cmd/node: Fix linter errors in config

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-06-02 15:44:41 +03:00 committed by Alex Vanin
parent e9e986ac71
commit a2547da5ae
9 changed files with 19 additions and 12 deletions

View file

@ -19,7 +19,7 @@ const (
// Returns DialTimeoutDefault if value is not positive duration.
func DialTimeout(c *config.Config) time.Duration {
v := config.DurationSafe(c.Sub(subsection), "dial_timeout")
if v != 0 {
if v > 0 {
return v
}

View file

@ -47,7 +47,7 @@ func New(_ Prm, opts ...Option) *Config {
err := v.ReadInConfig()
if err != nil {
panic(fmt.Errorf("failed to read config: %v", err))
panic(fmt.Errorf("failed to read config: %w", err))
}
}

View file

@ -15,7 +15,7 @@ const (
// RemoverBatchSizeDefault is a default batch size for Shard GC's remover.
RemoverBatchSizeDefault = 100
// RemoverSleepInterval is a default sleep interval of Shard GC's remover.
// RemoverSleepIntervalDefault is a default sleep interval of Shard GC's remover.
RemoverSleepIntervalDefault = time.Minute
)

View file

@ -6,7 +6,7 @@ import (
// config defaults
const (
// LevelDefault is a default logger level
// LevelDefault is a default logger level.
LevelDefault = "info"
)

View file

@ -27,7 +27,7 @@ func RPCEndpoint(c *config.Config) []string {
// Returns DialTimeoutDefault if value is not positive duration.
func DialTimeout(c *config.Config) time.Duration {
v := config.DurationSafe(c.Sub(subsection), "dial_timeout")
if v != 0 {
if v > 0 {
return v
}

View file

@ -9,17 +9,20 @@ import (
const (
subsection = "metrics"
// ShutdownTimeoutDefault is a default value for metrics HTTP service timeout.
ShutdownTimeoutDefault = 30 * time.Second
AddressDefault = ""
// AddressDefault is a default value for metrics HTTP service endpoint.
AddressDefault = ""
)
// ShutdownTimeout returns value of "shutdown_timeout" config parameter
// from "metrics" section.
//
// Returns ShutdownTimeoutDefault if value is not set.
// Returns ShutdownTimeoutDefault if value is not positive duration.
func ShutdownTimeout(c *config.Config) time.Duration {
v := config.DurationSafe(c.Sub(subsection), "shutdown_timeout")
if v != 0 {
if v > 0 {
return v
}

View file

@ -46,7 +46,7 @@ func NotificationEndpoint(c *config.Config) []string {
// Returns DialTimeoutDefault if value is not positive duration.
func DialTimeout(c *config.Config) time.Duration {
v := config.DurationSafe(c.Sub(subsection), "dial_timeout")
if v != 0 {
if v > 0 {
return v
}

View file

@ -9,17 +9,20 @@ import (
const (
subsection = "profiler"
// ShutdownTimeoutDefault is a default value for profiler HTTP service timeout.
ShutdownTimeoutDefault = 30 * time.Second
AddressDefault = ""
// AddressDefault is a default value for profiler HTTP service endpoint.
AddressDefault = ""
)
// ShutdownTimeout returns value of "shutdown_timeout" config parameter
// from "profiler" section.
//
// Returns ShutdownTimeoutDefault if value is not set.
// Returns ShutdownTimeoutDefault if value is not positive duration.
func ShutdownTimeout(c *config.Config) time.Duration {
v := config.DurationSafe(c.Sub(subsection), "shutdown_timeout")
if v != 0 {
if v > 0 {
return v
}

View file

@ -22,6 +22,7 @@ func fromEnvFile(path string) *config.Config {
var p config.Prm
loadEnv(path) // github.com/joho/godotenv can do that as well
return config.New(p)
}