forked from TrueCloudLab/frostfs-node
[#493] cmd/node: Add metrics section to config
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
da8310f0e3
commit
3fbf5e05b2
5 changed files with 88 additions and 1 deletions
40
cmd/neofs-node/config/metrics/config.go
Normal file
40
cmd/neofs-node/config/metrics/config.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package metricsconfig
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
||||
)
|
||||
|
||||
const (
|
||||
subsection = "metrics"
|
||||
|
||||
ShutdownTimeoutDefault = 30 * time.Second
|
||||
AddressDefault = ""
|
||||
)
|
||||
|
||||
// ShutdownTimeout returns value of "shutdown_timeout" config parameter
|
||||
// from "metrics" section.
|
||||
//
|
||||
// Returns ShutdownTimeoutDefault if value is not set.
|
||||
func ShutdownTimeout(c *config.Config) time.Duration {
|
||||
v := config.DurationSafe(c.Sub(subsection), "shutdown_timeout")
|
||||
if v != 0 {
|
||||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue