-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathEnvironmentQueuePresenter.server.ts
More file actions
33 lines (29 loc) · 1.11 KB
/
EnvironmentQueuePresenter.server.ts
File metadata and controls
33 lines (29 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { type AuthenticatedEnvironment } from "~/services/apiAuth.server";
import { marqs } from "~/v3/marqs/index.server";
import { engine } from "~/v3/runEngine.server";
import { BasePresenter } from "./basePresenter.server";
export type Environment = {
running: number;
queued: number;
concurrencyLimit: number;
burstFactor: number;
};
export class EnvironmentQueuePresenter extends BasePresenter {
async call(environment: AuthenticatedEnvironment): Promise<Environment> {
const [engineV1Executing, engineV2Executing, engineV1Queued, engineV2Queued] =
await Promise.all([
marqs.currentConcurrencyOfEnvironment(environment),
engine.concurrencyOfEnvQueue(environment),
marqs.lengthOfEnvQueue(environment),
engine.lengthOfEnvQueue(environment),
]);
const running = (engineV1Executing ?? 0) + (engineV2Executing ?? 0);
const queued = (engineV1Queued ?? 0) + (engineV2Queued ?? 0);
return {
running,
queued,
concurrencyLimit: environment.maximumConcurrencyLimit,
burstFactor: environment.concurrencyLimitBurstFactor.toNumber(),
};
}
}