[#493] cmd/node: Add replicator section to config
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
8c96494da0
commit
f40b84c99e
5 changed files with 67 additions and 0 deletions
27
cmd/neofs-node/config/replicator/config.go
Normal file
27
cmd/neofs-node/config/replicator/config.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package replicatorconfig
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
||||
)
|
||||
|
||||
const (
|
||||
subsection = "replicator"
|
||||
|
||||
// PutTimeoutDefault is a default timeout of object put request in replicator.
|
||||
PutTimeoutDefault = 5 * time.Second
|
||||
)
|
||||
|
||||
// PutTimeout returns value of "put_timeout" config parameter
|
||||
// from "replicator" section.
|
||||
//
|
||||
// Returns PutTimeoutDefault if value is not positive duration.
|
||||
func PutTimeout(c *config.Config) time.Duration {
|
||||
v := config.DurationSafe(c.Sub(subsection), "put_timeout")
|
||||
if v > 0 {
|
||||
return v
|
||||
}
|
||||
|
||||
return PutTimeoutDefault
|
||||
}
|
31
cmd/neofs-node/config/replicator/config_test.go
Normal file
31
cmd/neofs-node/config/replicator/config_test.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package replicatorconfig_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
||||
replicatorconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/replicator"
|
||||
configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestReplicatorSection(t *testing.T) {
|
||||
t.Run("defaults", func(t *testing.T) {
|
||||
empty := configtest.EmptyConfig()
|
||||
|
||||
require.Equal(t, replicatorconfig.PutTimeoutDefault, replicatorconfig.PutTimeout(empty))
|
||||
})
|
||||
|
||||
const path = "../../../../config/example/node"
|
||||
|
||||
var fileConfigTest = func(c *config.Config) {
|
||||
require.Equal(t, 15*time.Second, replicatorconfig.PutTimeout(c))
|
||||
}
|
||||
|
||||
configtest.ForEachFileType(path, fileConfigTest)
|
||||
|
||||
t.Run("ENV", func(t *testing.T) {
|
||||
configtest.ForEnvFileType(path, fileConfigTest)
|
||||
})
|
||||
}
|
|
@ -44,6 +44,9 @@ NEOFS_APICLIENT_DIAL_TIMEOUT=15s
|
|||
# Policer section
|
||||
NEOFS_POLICER_HEAD_TIMEOUT=15s
|
||||
|
||||
# Replicator section
|
||||
NEOFS_REPLICATOR_PUT_TIMEOUT=15s
|
||||
|
||||
# Storage engine section
|
||||
NEOFS_STORAGE_SHARD_NUM=2
|
||||
## 0 shard
|
||||
|
|
|
@ -64,6 +64,9 @@
|
|||
"policer": {
|
||||
"head_timeout": "15s"
|
||||
},
|
||||
"replicator": {
|
||||
"put_timeout": "15s"
|
||||
},
|
||||
"storage": {
|
||||
"shard_num": 2,
|
||||
"shard": {
|
||||
|
|
|
@ -57,6 +57,9 @@ apiclient:
|
|||
policer:
|
||||
head_timeout: 15s
|
||||
|
||||
replicator:
|
||||
put_timeout: 15s
|
||||
|
||||
storage:
|
||||
shard_num: 2
|
||||
shard:
|
||||
|
|
Loading…
Reference in a new issue