mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
lib/storage: code cleanup after 5bfd4e6218
This commit is contained in:
parent
4108e85efd
commit
64e2d66014
1 changed files with 8 additions and 8 deletions
|
@ -50,9 +50,9 @@ type Storage struct {
|
||||||
slowPerDayIndexInserts uint64
|
slowPerDayIndexInserts uint64
|
||||||
slowMetricNameLoads uint64
|
slowMetricNameLoads uint64
|
||||||
|
|
||||||
path string
|
path string
|
||||||
cachePath string
|
cachePath string
|
||||||
retentionMonths int
|
retentionMsecs int64
|
||||||
|
|
||||||
// lock file for exclusive access to the storage on the given path.
|
// lock file for exclusive access to the storage on the given path.
|
||||||
flockF *os.File
|
flockF *os.File
|
||||||
|
@ -118,11 +118,10 @@ func OpenStorage(path string, retentionMsecs int64) (*Storage, error) {
|
||||||
if retentionMsecs <= 0 {
|
if retentionMsecs <= 0 {
|
||||||
retentionMsecs = maxRetentionMsecs
|
retentionMsecs = maxRetentionMsecs
|
||||||
}
|
}
|
||||||
retentionMonths := (retentionMsecs + (msecsPerMonth - 1)) / msecsPerMonth
|
|
||||||
s := &Storage{
|
s := &Storage{
|
||||||
path: path,
|
path: path,
|
||||||
cachePath: path + "/cache",
|
cachePath: path + "/cache",
|
||||||
retentionMonths: int(retentionMonths),
|
retentionMsecs: retentionMsecs,
|
||||||
|
|
||||||
stop: make(chan struct{}),
|
stop: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
@ -473,8 +472,9 @@ func (s *Storage) startRetentionWatcher() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Storage) retentionWatcher() {
|
func (s *Storage) retentionWatcher() {
|
||||||
|
retentionMonths := int((s.retentionMsecs + (msecsPerMonth - 1)) / msecsPerMonth)
|
||||||
for {
|
for {
|
||||||
d := nextRetentionDuration(s.retentionMonths)
|
d := nextRetentionDuration(retentionMonths)
|
||||||
select {
|
select {
|
||||||
case <-s.stop:
|
case <-s.stop:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue