frostfs-node/cmd/frostfs-node/config/engine/shard/gc/config.go
Dmitrii Stepanov 07390ad4e3
All checks were successful
DCO action / DCO (pull_request) Successful in 2m54s
Vulncheck / Vulncheck (pull_request) Successful in 3m11s
Tests and linters / Staticcheck (pull_request) Successful in 3m55s
Build / Build Components (1.21) (pull_request) Successful in 3m51s
Build / Build Components (1.20) (pull_request) Successful in 4m6s
Tests and linters / Tests (1.21) (pull_request) Successful in 5m10s
Tests and linters / Lint (pull_request) Successful in 5m24s
Tests and linters / Tests (1.20) (pull_request) Successful in 6m56s
Tests and linters / Tests with -race (pull_request) Successful in 7m46s
[#715] node: Unify config parameter names
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-11-22 17:13:50 +03:00

98 lines
2.3 KiB
Go

package gcconfig
import (
"time"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
)
// Config is a wrapper over the config section
// which provides access to Shard's GC configurations.
type Config config.Config
const (
// RemoverBatchSizeDefault is a default batch size for Shard GC's remover.
RemoverBatchSizeDefault = 100
// RemoverSleepIntervalDefault is a default sleep interval of Shard GC's remover.
RemoverSleepIntervalDefault = time.Minute
// ExpiredCollectorWorkersCountDefault is a default workers count of Shard GC expired object collector.
ExpiredCollectorWorkersCountDefault = 5
// ExpiredCollectorBatchSizeDefault is a default batch size of Shard GC expired object collector.
ExpiredCollectorBatchSizeDefault = 500
)
// From wraps config section into Config.
func From(c *config.Config) *Config {
return (*Config)(c)
}
// RemoverBatchSize returns the value of "remover_batch_size"
// config parameter.
//
// Returns RemoverBatchSizeDefault if the value is not a positive number.
func (x *Config) RemoverBatchSize() int {
s := config.IntSafe(
(*config.Config)(x),
"remover_batch_size",
)
if s > 0 {
return int(s)
}
return RemoverBatchSizeDefault
}
// RemoverSleepInterval returns the value of "remover_sleep_interval"
// config parameter.
//
// Returns RemoverSleepIntervalDefault if the value is not a positive number.
func (x *Config) RemoverSleepInterval() time.Duration {
s := config.DurationSafe(
(*config.Config)(x),
"remover_sleep_interval",
)
if s > 0 {
return s
}
return RemoverSleepIntervalDefault
}
// ExpiredCollectorWorkerCount returns the value of "expired_collector_worker_count"
// config parameter.
//
// Returns ExpiredCollectorWorkersCountDefault if the value is not a positive number.
func (x *Config) ExpiredCollectorWorkerCount() int {
s := config.IntSafe(
(*config.Config)(x),
"expired_collector_worker_count",
)
if s > 0 {
return int(s)
}
return ExpiredCollectorWorkersCountDefault
}
// ExpiredCollectorBatchSize returns the value of "expired_collector_batch_size"
// config parameter.
//
// Returns ExpiredCollectorBatchSizeDefault if the value is not a positive number.
func (x *Config) ExpiredCollectorBatchSize() int {
s := config.IntSafe(
(*config.Config)(x),
"expired_collector_batch_size",
)
if s > 0 {
return int(s)
}
return ExpiredCollectorBatchSizeDefault
}