2021-06-01 11:20:03 +00:00
|
|
|
package metricsconfig
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
subsection = "metrics"
|
|
|
|
|
2021-06-02 12:44:41 +00:00
|
|
|
// ShutdownTimeoutDefault is a default value for metrics HTTP service timeout.
|
2021-06-01 11:20:03 +00:00
|
|
|
ShutdownTimeoutDefault = 30 * time.Second
|
2021-06-02 12:44:41 +00:00
|
|
|
|
|
|
|
// AddressDefault is a default value for metrics HTTP service endpoint.
|
|
|
|
AddressDefault = ""
|
2021-06-01 11:20:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ShutdownTimeout returns value of "shutdown_timeout" config parameter
|
|
|
|
// from "metrics" section.
|
|
|
|
//
|
2021-06-02 12:44:41 +00:00
|
|
|
// Returns ShutdownTimeoutDefault if value is not positive duration.
|
2021-06-01 11:20:03 +00:00
|
|
|
func ShutdownTimeout(c *config.Config) time.Duration {
|
|
|
|
v := config.DurationSafe(c.Sub(subsection), "shutdown_timeout")
|
2021-06-02 12:44:41 +00:00
|
|
|
if v > 0 {
|
2021-06-01 11:20:03 +00:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
return ShutdownTimeoutDefault
|
|
|
|
}
|
|
|
|
|
|
|
|
// Address returns value of "address" config parameter
|
|
|
|
// from "metrics" section.
|
|
|
|
//
|
|
|
|
// Returns AddressDefault if value is not set.
|
|
|
|
func Address(c *config.Config) string {
|
|
|
|
v := config.StringSafe(c.Sub(subsection), "address")
|
|
|
|
if v != "" {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
return AddressDefault
|
|
|
|
}
|