task max of 0 should mean infinite

This commit is contained in:
Andrew Jackson (Ajax) 2023-10-30 18:25:16 -05:00
parent 3b6e59378e
commit daebec76bf
2 changed files with 4 additions and 2 deletions

View File

@ -19,7 +19,7 @@ var FOLLOW_FREQUENCY = 1 * time.Minute // Check for work to follow this often
type TaskTypeDetails struct { type TaskTypeDetails struct {
// Max returns how many tasks this machine can run of this type. // Max returns how many tasks this machine can run of this type.
// Negative means unrestricted. // Zero (default) or less means unrestricted.
Max int Max int
// Name is the task name to be added to the task list. // Name is the task name to be added to the task list.

View File

@ -57,7 +57,9 @@ top:
} }
// 1. Can we do any more of this task type? // 1. Can we do any more of this task type?
if h.Max > -1 && int(h.Count.Load()) == h.Max { // NOTE: 0 is the default value, so this way people don't need to worry about
// this setting unless they want to limit the number of tasks of this type.
if h.Max > 0 && int(h.Count.Load()) >= h.Max {
log.Debugw("did not accept task", "name", h.Name, "reason", "at max already") log.Debugw("did not accept task", "name", h.Name, "reason", "at max already")
return false return false
} }