98 lines
2.3 KiB
Go
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
|
|
}
|