[#71] Make GC configurable

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-10-05 13:44:28 +03:00 committed by Alex Vanin
parent 7a2654719e
commit a9e801cb22
2 changed files with 12 additions and 2 deletions

View file

@ -46,6 +46,7 @@ const (
cfgNodeKey = "node.key"
cfgBootstrapAddress = "node.address"
cfgNodeAttributePrefix = "node.attribute"
cfgMaxObjectSize = "node.maxobjectsize" // todo: get value from chain
// config keys for cfgGRPC
cfgListenAddress = "grpc.endpoint"
@ -66,10 +67,12 @@ const (
cfgContainerContract = "container.scripthash"
cfgContainerFee = "container.fee"
cfgMaxObjectSize = "node.maxobjectsize" // get value from chain
cfgObjectStorage = "storage.object"
cfgMetaStorage = "storage.meta"
cfgGCQueueSize = "gc.queuesize"
cfgGCQueueTick = "gc.duration.sleep"
cfgGCTimeout = "gc.duration.timeout"
)
const (
@ -286,6 +289,10 @@ func defaultConfiguration(v *viper.Viper) {
v.SetDefault(cfgProfilerEnable, false)
v.SetDefault(cfgProfilerAddr, ":6060")
v.SetDefault(cfgProfilerTTL, "30s")
v.SetDefault(cfgGCQueueSize, 1000)
v.SetDefault(cfgGCQueueTick, "5s")
v.SetDefault(cfgGCTimeout, "5s")
}
func (c *cfg) LocalAddress() *network.Address {

View file

@ -192,6 +192,9 @@ func initObjectService(c *cfg) {
objGC := gc.New(
gc.WithLogger(c.log),
gc.WithRemover(ls),
gc.WithQueueCapacity(c.viper.GetUint32(cfgGCQueueSize)),
gc.WithSleepInterval(c.viper.GetDuration(cfgGCQueueTick)),
gc.WithWorkingInterval(c.viper.GetDuration(cfgGCTimeout)),
)
c.workers = append(c.workers, objGC)