Use tickers instead of for loops with sleep, replace interface{} with any

This commit is contained in:
eleksir
2025-03-28 02:34:32 +03:00
parent 40eaac419d
commit b8b9ba2c2c
9 changed files with 31 additions and 33 deletions

View File

@@ -16,12 +16,13 @@ type Mem struct {
// UpdateMemStats parses mem info stats.
func (c *MyConfig) UpdateMemStats() {
for {
ticker := time.NewTicker(time.Second * 3)
for range ticker.C {
v, err := mem.VirtualMemory()
if err != nil {
log.Printf("Unable to get memory statistics: %s", err)
time.Sleep(1 * time.Second)
continue
}
@@ -30,7 +31,6 @@ func (c *MyConfig) UpdateMemStats() {
if err != nil {
log.Printf("Unable to get swap statistics: %s", err)
time.Sleep(1 * time.Second)
continue
}
@@ -49,7 +49,5 @@ func (c *MyConfig) UpdateMemStats() {
c.Channels.UpdateReady <- true
}
}
time.Sleep(3 * time.Second)
}
}