7a89225d72
Finishes device refactoring: temps Refactoring to allow updating maps. Simpler, and optimizable.
27 lines
466 B
Go
27 lines
466 B
Go
package devices
|
|
|
|
import "log"
|
|
|
|
var memFuncs []func(map[string]MemoryInfo) map[string]error
|
|
|
|
type MemoryInfo struct {
|
|
Total uint64
|
|
Used uint64
|
|
UsedPercent float64
|
|
}
|
|
|
|
func RegisterMem(f func(map[string]MemoryInfo) map[string]error) {
|
|
memFuncs = append(memFuncs, f)
|
|
}
|
|
|
|
func UpdateMem(mem map[string]MemoryInfo) {
|
|
for _, f := range memFuncs {
|
|
errs := f(mem)
|
|
if errs != nil {
|
|
for k, e := range errs {
|
|
log.Printf("%s: %s", k, e)
|
|
}
|
|
}
|
|
}
|
|
}
|