Skip to content

Commit

Permalink
fix golangci critics
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Nov 14, 2024
1 parent ccecfff commit 3e84689
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/modgearman/configuration_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type config struct {
loadLimit5 float64
loadLimit15 float64
loadCPUMulti float64
memLimit int
memLimit uint64
backgroundingThreshold int
showErrorOutput bool
dupResultsArePassive bool
Expand Down Expand Up @@ -277,7 +277,7 @@ func (config *config) parseConfigItem(raw string) error {
case "load_cpu_multi":
config.loadCPUMulti = getFloat(value)
case "mem_limit":
config.memLimit = getInt(value)
config.memLimit = uint64(getFloat(value))
case "backgrounding-threshold":
config.backgroundingThreshold = getInt(value)
case "show_error_output":
Expand Down
3 changes: 2 additions & 1 deletion pkg/modgearman/mainWorker.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func (w *mainWorker) checkMemory() (ok bool, reason string) {
}

usedPercent := 100 - (w.memFree*100)/w.memTotal
if w.cfg.memLimit > 0 && usedPercent >= uint64(w.cfg.memLimit) {
if w.cfg.memLimit > 0 && usedPercent >= w.cfg.memLimit {
reason := fmt.Sprintf("cannot start any more worker, memory usage is too high: %d%% > %d%% (free: %s)",
usedPercent,
w.cfg.memLimit,
Expand Down Expand Up @@ -621,5 +621,6 @@ func bytes2Human(num uint64) string {
div *= unit
exp++
}

return fmt.Sprintf("%.2f %cB", float64(num)/float64(div), "KMGTPE"[exp])
}

0 comments on commit 3e84689

Please sign in to comment.