* The backstop: answer a caller whose call is not done, and say in the log * which it was, a call no worker had reached or one a worker is still on. * The tool's name only, never its arguments: a query can be the user's code.
(job: Job)
| 515 | * The tool's name only, never its arguments: a query can be the user's code. |
| 516 | */ |
| 517 | private answerBusy(job: Job): void { |
| 518 | const now = Date.now(); |
| 519 | job.busyAt = now; |
| 520 | if (job.startedAt === undefined) { |
| 521 | this.log( |
| 522 | `${job.toolName} was answered "busy" after ${logSecs(now - job.enqueuedAt)} in the queue: no worker was free ` + |
| 523 | `(${this.inflight.size} of ${this.workers.size} running a call, ${this.queue.filter((queued) => !queued.settled).length} waiting).`, |
| 524 | ); |
| 525 | this.settle(job, busyGuidance(now - job.enqueuedAt)); |
| 526 | return; |
| 527 | } |
| 528 | this.log( |
| 529 | `${job.toolName} was answered "busy" after ${logSecs(now - job.enqueuedAt)}: it waited ${logSecs(job.startedAt - job.enqueuedAt)} ` + |
| 530 | `for a worker and has been running for ${logSecs(now - job.startedAt)}. The worker stays on it until it finishes.`, |
| 531 | ); |
| 532 | this.settle(job, busyGuidance(job.startedAt - job.enqueuedAt, now - job.startedAt)); |
| 533 | } |
| 534 | |
| 535 | /** A worker has finished `job`: log it when it was slow, or when its caller had stopped waiting. */ |
| 536 | private noteFinished(job: Job): void { |
no test coverage detected