From 64e2d660145d73dbcc3366ae76f6b61bd6b06362 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 20 Oct 2020 16:10:46 +0300 Subject: [PATCH] lib/storage: code cleanup after 5bfd4e62188f74606b463aab3135beb17a8456c8 --- lib/storage/storage.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/storage/storage.go b/lib/storage/storage.go index ee8e53ca7b..a4106901c4 100644 --- a/lib/storage/storage.go +++ b/lib/storage/storage.go @@ -50,9 +50,9 @@ type Storage struct { slowPerDayIndexInserts uint64 slowMetricNameLoads uint64 - path string - cachePath string - retentionMonths int + path string + cachePath string + retentionMsecs int64 // lock file for exclusive access to the storage on the given path. flockF *os.File @@ -118,11 +118,10 @@ func OpenStorage(path string, retentionMsecs int64) (*Storage, error) { if retentionMsecs <= 0 { retentionMsecs = maxRetentionMsecs } - retentionMonths := (retentionMsecs + (msecsPerMonth - 1)) / msecsPerMonth s := &Storage{ - path: path, - cachePath: path + "/cache", - retentionMonths: int(retentionMonths), + path: path, + cachePath: path + "/cache", + retentionMsecs: retentionMsecs, stop: make(chan struct{}), } @@ -473,8 +472,9 @@ func (s *Storage) startRetentionWatcher() { } func (s *Storage) retentionWatcher() { + retentionMonths := int((s.retentionMsecs + (msecsPerMonth - 1)) / msecsPerMonth) for { - d := nextRetentionDuration(s.retentionMonths) + d := nextRetentionDuration(retentionMonths) select { case <-s.stop: return