BREAKING CHANGE(constraints): make TaskConstraintGroup constraint matcher input-aware and add shouldExecute pre-execution hook
This commit is contained in:
@@ -12,11 +12,13 @@
|
||||
- Typed data bag accessible as `task.data`
|
||||
|
||||
### TaskConstraintGroup
|
||||
- `new TaskConstraintGroup<TData>({ name, constraintKeyForTask, maxConcurrent?, cooldownMs? })`
|
||||
- `constraintKeyForTask(task)` returns a string key (constraint applies) or `null` (skip)
|
||||
- `new TaskConstraintGroup<TData>({ name, constraintKeyForExecution, maxConcurrent?, cooldownMs?, shouldExecute? })`
|
||||
- `constraintKeyForExecution(task, input?)` returns a string key (constraint applies) or `null` (skip). Receives both task and runtime input.
|
||||
- `shouldExecute(task, input?)` — optional pre-execution check. Returns `false` to skip (deferred resolves `undefined`). Can be async.
|
||||
- `maxConcurrent` (default: `Infinity`) — max concurrent tasks per key
|
||||
- `cooldownMs` (default: `0`) — minimum ms gap between completions per key
|
||||
- Methods: `canRun(key)`, `acquireSlot(key)`, `releaseSlot(key)`, `getCooldownRemaining(key)`, `getRunningCount(key)`, `reset()`
|
||||
- Methods: `getConstraintKey(task, input?)`, `checkShouldExecute(task, input?)`, `canRun(key)`, `acquireSlot(key)`, `releaseSlot(key)`, `getCooldownRemaining(key)`, `getRunningCount(key)`, `reset()`
|
||||
- `ITaskExecution<TData>` type exported from index — `{ task, input }` tuple
|
||||
|
||||
### TaskManager Constraint Integration
|
||||
- `manager.addConstraintGroup(group)` / `manager.removeConstraintGroup(name)`
|
||||
|
||||
Reference in New Issue
Block a user