diff --git a/cmd/neofs-node/config/object/config.go b/cmd/neofs-node/config/object/config.go new file mode 100644 index 00000000..79f3df75 --- /dev/null +++ b/cmd/neofs-node/config/object/config.go @@ -0,0 +1,41 @@ +package objectconfig + +import ( + "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" +) + +// PutConfig is a wrapper over "put" config section which provides access +// to object put pipeline configuration of object service. +type PutConfig struct { + cfg *config.Config +} + +const ( + subsection = "object" + + putSubsection = "put" + + // PutPoolSizeDefault is a default value of routine pool size to + // process object.Put requests in object service. + PutPoolSizeDefault = 10 +) + +// Put returns structure that provides access to "put" subsection of +// "object" section. +func Put(c *config.Config) PutConfig { + return PutConfig{ + c.Sub(subsection).Sub(putSubsection), + } +} + +// PoolSize returns value of "pool_size" config parameter. +// +// Returns PutPoolSizeDefault if value is not positive number. +func (g PutConfig) PoolSize() int { + v := config.Int(g.cfg, "pool_size") + if v > 0 { + return int(v) + } + + return PutPoolSizeDefault +} diff --git a/cmd/neofs-node/config/object/config_test.go b/cmd/neofs-node/config/object/config_test.go new file mode 100644 index 00000000..a2d6b619 --- /dev/null +++ b/cmd/neofs-node/config/object/config_test.go @@ -0,0 +1,30 @@ +package objectconfig_test + +import ( + "testing" + + "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" + objectconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/object" + configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test" + "github.com/stretchr/testify/require" +) + +func TestObjectSection(t *testing.T) { + t.Run("defaults", func(t *testing.T) { + empty := configtest.EmptyConfig() + + require.Equal(t, objectconfig.PutPoolSizeDefault, objectconfig.Put(empty).PoolSize()) + }) + + const path = "../../../../config/example/node" + + var fileConfigTest = func(c *config.Config) { + require.Equal(t, 100, objectconfig.Put(c).PoolSize()) + } + + configtest.ForEachFileType(path, fileConfigTest) + + t.Run("ENV", func(t *testing.T) { + configtest.ForEnvFileType(path, fileConfigTest) + }) +} diff --git a/config/example/node.env b/config/example/node.env index 6ba00aef..4d56ad36 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -47,6 +47,9 @@ NEOFS_POLICER_HEAD_TIMEOUT=15s # Replicator section NEOFS_REPLICATOR_PUT_TIMEOUT=15s +# Object service section +NEOFS_OBJECT_PUT_POOL_SIZE=100 + # Storage engine section NEOFS_STORAGE_SHARD_NUM=2 ## 0 shard diff --git a/config/example/node.json b/config/example/node.json index e5489ac4..61254461 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -67,6 +67,11 @@ "replicator": { "put_timeout": "15s" }, + "object": { + "put": { + "pool_size": 100 + } + }, "storage": { "shard_num": 2, "shard": { diff --git a/config/example/node.yaml b/config/example/node.yaml index e3d8db53..ba0028e0 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -60,6 +60,10 @@ policer: replicator: put_timeout: 15s +object: + put: + pool_size: 100 + storage: shard_num: 2 shard: