Commit 6060b9c8 authored by nanahira's avatar nanahira

fix dispatcher active

parent 30b4b5e4
......@@ -441,11 +441,16 @@ export class WorkflowDispatcher<F extends (...args: any[]) => Promise<any>> {
}
private isEligibleActive(i: number, now: number) {
const slot = this.slots[i];
if (!slot || slot.kind !== 'active') return false;
const s = slot.state;
return !s.running && now >= s.nextAvailableAt;
// note: specific queues ignore backoff; this is only for global picks.
const slot = this.slots[i] as ActiveSlot<F>;
const slotGood = (s: ActiveSlot<F>) =>
s.kind === 'active' && !s.state.running;
if (!slotGood(slot)) return false;
if (now >= slot.state.nextAvailableAt) return true;
return !this.slots.some((other: ActiveSlot<F>, j) => {
if (j === i) return false;
if (!slotGood(other)) return false;
return now >= other.state.nextAvailableAt;
});
}
private pickBestActiveForGlobal(): number {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment