2021-06-02 12:23:41 +00:00
|
|
|
package policerconfig
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
subsection = "policer"
|
|
|
|
|
|
|
|
// HeadTimeoutDefault is a default object.Head request timeout in policer.
|
|
|
|
HeadTimeoutDefault = 5 * time.Second
|
|
|
|
)
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// HeadTimeout returns the value of "head_timeout" config parameter
|
2021-06-02 12:23:41 +00:00
|
|
|
// from "policer" section.
|
|
|
|
//
|
2022-04-21 11:28:05 +00:00
|
|
|
// Returns HeadTimeoutDefault if the value is not positive duration.
|
2021-06-02 12:23:41 +00:00
|
|
|
func HeadTimeout(c *config.Config) time.Duration {
|
|
|
|
v := config.DurationSafe(c.Sub(subsection), "head_timeout")
|
|
|
|
if v > 0 {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
return HeadTimeoutDefault
|
|
|
|
}
|