@oneuptime/common 14.0.5 → 14.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/DatabaseModels/InventoryItem.ts +23 -12
- package/Server/Infrastructure/Postgres/SchemaMigrations/1795200000000-AddInventoryItemProjectEntityKeyIndex.ts +217 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Services/AlertService.ts +32 -36
- package/Server/Services/IncidentAlertService.ts +609 -2
- package/Server/Services/IncidentService.ts +134 -44
- package/Server/Services/InventoryItemService.ts +38 -0
- package/Server/Services/IoTDeviceCredentialService.ts +13 -4
- package/Server/Services/MetricService.ts +1 -1
- package/Server/Services/ScheduledMaintenanceService.ts +50 -46
- package/Server/Services/UserNotificationRuleService.ts +55 -53
- package/Server/Services/WorkspaceNotificationSummaryService.ts +38 -20
- package/Server/Types/Database/QueryHelper.ts +54 -1
- package/Server/Utils/AI/Toolbox/MetricTools.ts +13 -2
- package/Server/Utils/AI/Toolbox/ResourceTools.ts +12 -1
- package/Server/Utils/AffectedResources/LinkedAffectedResources.ts +576 -0
- package/Server/Utils/Alert/AlertStateChangeAuthorization.ts +129 -0
- package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +1 -1
- package/Server/Utils/Inventory/InventoryOverviewAggregation.ts +111 -0
- package/Server/Utils/Monitor/Criteria/CompareCriteria.ts +33 -0
- package/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.ts +4 -3
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +3 -1
- package/Server/Utils/Response.ts +31 -0
- package/Server/Utils/Topology/TopologyConcurrencyLimiter.ts +229 -0
- package/Server/Utils/Topology/TopologyQueries.ts +1350 -0
- package/Server/Utils/Topology/TopologyRequest.ts +463 -0
- package/Server/Utils/Topology/TopologyResponseCache.ts +183 -0
- package/Server/Utils/Topology/TopologySql.ts +1024 -0
- package/Tests/App/Dashboard/AcknowledgeAlertsOnDeclare.test.ts +369 -0
- package/Tests/App/Dashboard/AffectedResourcesSlo.test.tsx +1 -1
- package/Tests/App/Dashboard/AffectedResourcesSummaryStep.test.tsx +510 -123
- package/Tests/App/Dashboard/AlertsTableAffectedResources.test.tsx +490 -0
- package/Tests/App/Dashboard/ChangeAlertStateDeclareIncident.test.tsx +886 -0
- package/Tests/App/Dashboard/CreateReviewStepRoleSummary.test.tsx +1250 -0
- package/Tests/App/Dashboard/CreateReviewStepSelectionSummary.test.tsx +738 -0
- package/Tests/App/Dashboard/DeclareIncidentFromAlert.test.ts +417 -0
- package/Tests/App/Dashboard/EntityDetailPanel.test.tsx +1948 -229
- package/Tests/App/Dashboard/EntityDetailPanelLifecycle.test.tsx +493 -0
- package/Tests/App/Dashboard/EntityDetailPanelNavigation.test.tsx +439 -0
- package/Tests/App/Dashboard/EventOverviewPages.test.tsx +292 -1
- package/Tests/App/Dashboard/EventStatusPanel.test.tsx +798 -2
- package/Tests/App/Dashboard/FetchStateAndSeverityElements.test.tsx +669 -0
- package/Tests/App/Dashboard/FetchUsers.test.tsx +230 -0
- package/Tests/App/Dashboard/IncidentCreateAcknowledgeAlerts.test.tsx +1611 -0
- package/Tests/App/Dashboard/InfrastructureExplorer.test.tsx +1365 -57
- package/Tests/App/Dashboard/InfrastructureGraph.test.tsx +964 -23
- package/Tests/App/Dashboard/InventoryRelationships.test.tsx +885 -0
- package/Tests/App/Dashboard/NetworkTopologyExplorerSearch.test.tsx +1267 -0
- package/Tests/App/Dashboard/ResourceOverviewTileTooltips.test.tsx +4 -1
- package/Tests/App/Dashboard/RumOverviewPage.test.tsx +127 -0
- package/Tests/App/Dashboard/ServiceMapDatabaseLink.test.tsx +201 -15
- package/Tests/App/Dashboard/ServiceMapGraph.test.tsx +508 -36
- package/Tests/App/Dashboard/SiteSearchBox.test.tsx +2110 -0
- package/Tests/App/Dashboard/TelemetryMetricsSignals.test.ts +168 -8
- package/Tests/App/Dashboard/TopologyDataLifecycle.test.tsx +583 -0
- package/Tests/App/Dashboard/TopologyDataLoading.test.tsx +982 -218
- package/Tests/App/Dashboard/TopologyPageNavigation.test.tsx +818 -114
- package/Tests/Server/Infrastructure/Postgres/RenameInventoryItemMigration.test.ts +90 -21
- package/Tests/Server/Services/DomainService.test.ts +525 -0
- package/Tests/Server/Services/IncidentAlertAcknowledgeOnDeclare.test.ts +2630 -0
- package/Tests/Server/Services/IncidentAlertPostgres.test.ts +1625 -1
- package/Tests/Server/Services/IncidentDeclareAcknowledgeAlerts.test.ts +2189 -0
- package/Tests/Server/Services/InventoryItemServiceOverviewCounts.test.ts +345 -0
- package/Tests/Server/Services/InventoryOverviewPostgres.test.ts +254 -0
- package/Tests/Server/Services/IoTDeviceCredentialService.test.ts +819 -0
- package/Tests/Server/Services/LinkedAffectedResourcesCreatedFeed.test.ts +420 -0
- package/Tests/Server/Services/MetricServiceAggregate.test.ts +12 -0
- package/Tests/Server/Services/SavedViewDefaults.test.ts +325 -0
- package/Tests/Server/Services/SloAffectedResourceCreatedFeed.test.ts +92 -36
- package/Tests/Server/Services/StatusPageCertificateService.test.ts +169 -0
- package/Tests/Server/Services/TeamComplianceSettingService.test.ts +191 -0
- package/Tests/Server/Types/Database/QueryHelperSearchAllWords.test.ts +651 -0
- package/Tests/Server/Utils/AI/AlertWriteTools.test.ts +256 -0
- package/Tests/Server/Utils/AI/IncidentWriteTools.test.ts +482 -0
- package/Tests/Server/Utils/AffectedResources/LinkedAffectedResources.test.ts +858 -0
- package/Tests/Server/Utils/Alert/AlertStateChangeAuthorization.test.ts +1172 -0
- package/Tests/Server/Utils/Monitor/Criteria/CompareCriteria.test.ts +54 -0
- package/Tests/Server/Utils/Monitor/MetricDecimalThreshold.test.ts +417 -0
- package/Tests/Server/Utils/Monitor/MonitorCriteriaEvaluatorAffectedResourceEdgeCases.test.ts +96 -0
- package/Tests/Server/Utils/Topology/InventoryItemEntityKeyIndexMigration.test.ts +386 -0
- package/Tests/Server/Utils/Topology/InventoryItemEntityKeyIndexMigrationPostgres.test.ts +430 -0
- package/Tests/Server/Utils/Topology/TopologyActivityParityPostgres.test.ts +279 -0
- package/Tests/Server/Utils/Topology/TopologyConcurrencyLimiter.test.ts +534 -0
- package/Tests/Server/Utils/Topology/TopologyEstateGenerator.ts +624 -0
- package/Tests/Server/Utils/Topology/TopologyJsonResponse.test.ts +90 -0
- package/Tests/Server/Utils/Topology/TopologyQueries.test.ts +1634 -0
- package/Tests/Server/Utils/Topology/TopologyQueriesDifferentialPostgres.test.ts +683 -0
- package/Tests/Server/Utils/Topology/TopologyQueriesPostgres.test.ts +2624 -0
- package/Tests/Server/Utils/Topology/TopologyReference.ts +1018 -0
- package/Tests/Server/Utils/Topology/TopologyRequest.test.ts +643 -0
- package/Tests/Server/Utils/Topology/TopologyResponseCache.test.ts +305 -0
- package/Tests/Server/Utils/Topology/TopologySql.test.ts +973 -0
- package/Tests/Types/BaseDatabase/AggregationType.test.ts +5 -1
- package/Tests/Types/Dashboard/KubernetesDashboardTemplate.test.ts +184 -0
- package/Tests/Types/Dashboard/KubernetesDashboardTemplates.test.ts +107 -0
- package/Tests/Types/Monitor/KubernetesAlertTemplates.test.ts +8 -14
- package/Tests/Types/Monitor/KubernetesMetricCatalog.test.ts +4 -3
- package/Tests/Types/Monitor/Utils/KubernetesAgentEmittedMetrics.ts +27 -6
- package/Tests/Types/Topology/TopologyTypeRules.test.ts +176 -0
- package/Tests/UI/Rum/ChunkLoader.test.ts +76 -0
- package/Tests/UI/Rum/ReplayRailDetail.test.tsx +53 -0
- package/Tests/UI/Rum/ReplaySignals.test.ts +54 -0
- package/Tests/Utils/Dashboard/KubernetesClusterCpuTileRepair.test.ts +370 -0
- package/Tests/Utils/Incident/IncidentFromAlerts.test.ts +302 -0
- package/Tests/Utils/Rules/MonitorTypeRuleCriteria.test.ts +181 -0
- package/Types/BaseDatabase/AggregationType.ts +7 -0
- package/Types/Dashboard/DashboardTemplates.ts +20 -7
- package/Types/Incident/IncidentAlertLink.ts +19 -0
- package/Types/Rum/SessionReplayCustomEvents.ts +29 -3
- package/Types/Rum/WebVitals.ts +13 -0
- package/Types/Telemetry/InventoryLiveness.ts +26 -0
- package/Types/Topology/TopologyApi.ts +428 -0
- package/Types/Topology/TopologyTypeRules.ts +191 -0
- package/UI/Components/Input/Input.tsx +11 -0
- package/Utils/Dashboard/KubernetesClusterCpuTileRepair.ts +147 -0
- package/Utils/Incident/IncidentFromAlerts.ts +78 -0
- package/build/dist/Models/DatabaseModels/InventoryItem.js +20 -11
- package/build/dist/Models/DatabaseModels/InventoryItem.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795200000000-AddInventoryItemProjectEntityKeyIndex.js +165 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795200000000-AddInventoryItemProjectEntityKeyIndex.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AlertService.js +21 -33
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/IncidentAlertService.js +457 -3
- package/build/dist/Server/Services/IncidentAlertService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +96 -42
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/InventoryItemService.js +31 -0
- package/build/dist/Server/Services/InventoryItemService.js.map +1 -1
- package/build/dist/Server/Services/IoTDeviceCredentialService.js +12 -5
- package/build/dist/Server/Services/IoTDeviceCredentialService.js.map +1 -1
- package/build/dist/Server/Services/MetricService.js +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +37 -40
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +55 -51
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js +42 -25
- package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js.map +1 -1
- package/build/dist/Server/Types/Database/QueryHelper.js +47 -1
- package/build/dist/Server/Types/Database/QueryHelper.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js +13 -2
- package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/ResourceTools.js +12 -1
- package/build/dist/Server/Utils/AI/Toolbox/ResourceTools.js.map +1 -1
- package/build/dist/Server/Utils/AffectedResources/LinkedAffectedResources.js +405 -0
- package/build/dist/Server/Utils/AffectedResources/LinkedAffectedResources.js.map +1 -0
- package/build/dist/Server/Utils/Alert/AlertStateChangeAuthorization.js +112 -0
- package/build/dist/Server/Utils/Alert/AlertStateChangeAuthorization.js.map +1 -0
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +1 -1
- package/build/dist/Server/Utils/Inventory/InventoryOverviewAggregation.js +81 -0
- package/build/dist/Server/Utils/Inventory/InventoryOverviewAggregation.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js +31 -0
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Response.js +30 -0
- package/build/dist/Server/Utils/Response.js.map +1 -1
- package/build/dist/Server/Utils/Topology/TopologyConcurrencyLimiter.js +178 -0
- package/build/dist/Server/Utils/Topology/TopologyConcurrencyLimiter.js.map +1 -0
- package/build/dist/Server/Utils/Topology/TopologyQueries.js +884 -0
- package/build/dist/Server/Utils/Topology/TopologyQueries.js.map +1 -0
- package/build/dist/Server/Utils/Topology/TopologyRequest.js +275 -0
- package/build/dist/Server/Utils/Topology/TopologyRequest.js.map +1 -0
- package/build/dist/Server/Utils/Topology/TopologyResponseCache.js +146 -0
- package/build/dist/Server/Utils/Topology/TopologyResponseCache.js.map +1 -0
- package/build/dist/Server/Utils/Topology/TopologySql.js +688 -0
- package/build/dist/Server/Utils/Topology/TopologySql.js.map +1 -0
- package/build/dist/Types/BaseDatabase/AggregationType.js +7 -0
- package/build/dist/Types/BaseDatabase/AggregationType.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardTemplates.js +20 -7
- package/build/dist/Types/Dashboard/DashboardTemplates.js.map +1 -1
- package/build/dist/Types/Incident/IncidentAlertLink.js +17 -0
- package/build/dist/Types/Incident/IncidentAlertLink.js.map +1 -1
- package/build/dist/Types/Rum/SessionReplayCustomEvents.js.map +1 -1
- package/build/dist/Types/Rum/WebVitals.js +12 -0
- package/build/dist/Types/Rum/WebVitals.js.map +1 -1
- package/build/dist/Types/Telemetry/InventoryLiveness.js +23 -0
- package/build/dist/Types/Telemetry/InventoryLiveness.js.map +1 -1
- package/build/dist/Types/Topology/TopologyApi.js +55 -0
- package/build/dist/Types/Topology/TopologyApi.js.map +1 -0
- package/build/dist/Types/Topology/TopologyTypeRules.js +165 -0
- package/build/dist/Types/Topology/TopologyTypeRules.js.map +1 -0
- package/build/dist/UI/Components/Input/Input.js +1 -1
- package/build/dist/UI/Components/Input/Input.js.map +1 -1
- package/build/dist/Utils/Dashboard/KubernetesClusterCpuTileRepair.js +110 -0
- package/build/dist/Utils/Dashboard/KubernetesClusterCpuTileRepair.js.map +1 -0
- package/build/dist/Utils/Incident/IncidentFromAlerts.js +38 -0
- package/build/dist/Utils/Incident/IncidentFromAlerts.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import TooManyRequestsException from "../../../Types/Exception/TooManyRequestsException";
|
|
2
|
+
/*
|
|
3
|
+
* Bounds the Topology API's database work in one API process.
|
|
4
|
+
*
|
|
5
|
+
* Every Topology request reads in its own snapshot on one pooled connection
|
|
6
|
+
* (TopologyQueries.inReadOnlySnapshot), and a map build is among the heaviest
|
|
7
|
+
* reads in the app — a whole-inventory pass that can take seconds on a large
|
|
8
|
+
* project. The response cache shares a build between viewers of the same
|
|
9
|
+
* (project, minute), but callers choose the minute and the drawer and
|
|
10
|
+
* collection reads are not cached at all, so nothing else stops a burst of
|
|
11
|
+
* them from taking the connection pool (shared with ingest, alerting and
|
|
12
|
+
* every other request on the process) and the database CPU with it.
|
|
13
|
+
*
|
|
14
|
+
* So at most `maxRunning` of them run at once per process, and at most
|
|
15
|
+
* `maxRunningPerProject` for any one project, so one busy project cannot
|
|
16
|
+
* occupy every slot. The rest wait in arrival order WITHOUT holding a
|
|
17
|
+
* connection: a released slot goes to the first waiter whose project is
|
|
18
|
+
* under its own limit, so a project at its limit never holds up another
|
|
19
|
+
* project queued behind it. The queue is bounded too — per process and per
|
|
20
|
+
* project — and a request that finds it full, or waits longer than
|
|
21
|
+
* `maxWaitMs`, is answered 429 (TooManyRequestsException) at once: the
|
|
22
|
+
* Dashboard shows "busy, try again" rather than a request that hangs.
|
|
23
|
+
*
|
|
24
|
+
* A request whose client has gone (the drawer aborts the previous entity's
|
|
25
|
+
* load on every click) gives up its queue place at once and never starts:
|
|
26
|
+
* otherwise one person clicking through the drawer would queue dead reads
|
|
27
|
+
* ahead of the one they are waiting for and fill their project's queue.
|
|
28
|
+
*
|
|
29
|
+
* Per process, like the response cache; there is no cross-process
|
|
30
|
+
* coordination, so the cluster-wide bound is this times the API replicas.
|
|
31
|
+
*/
|
|
32
|
+
export const TOPOLOGY_BUSY_MESSAGE = "The topology service is busy. Try again in a moment.";
|
|
33
|
+
/* Sent as Retry-After with a 429 from the Topology API. */
|
|
34
|
+
export const TOPOLOGY_BUSY_RETRY_AFTER_SECONDS = 5;
|
|
35
|
+
export const TOPOLOGY_CONCURRENCY_LIMITS = {
|
|
36
|
+
maxRunning: 4,
|
|
37
|
+
maxRunningPerProject: 2,
|
|
38
|
+
maxWaiting: 64,
|
|
39
|
+
maxWaitingPerProject: 16,
|
|
40
|
+
maxWaitMs: 30000,
|
|
41
|
+
};
|
|
42
|
+
/* The caller went away before its read started; nobody is waiting for it. */
|
|
43
|
+
export class TopologyRequestAbandonedError extends Error {
|
|
44
|
+
constructor() {
|
|
45
|
+
super("The Topology request was abandoned by its client.");
|
|
46
|
+
this.name = "TopologyRequestAbandonedError";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class TopologyConcurrencyLimiter {
|
|
50
|
+
constructor(limits = TOPOLOGY_CONCURRENCY_LIMITS) {
|
|
51
|
+
this.limits = limits;
|
|
52
|
+
this.running = 0;
|
|
53
|
+
this.runningByProject = new Map();
|
|
54
|
+
/*
|
|
55
|
+
* Arrival order. Invariant between calls: no waiter here could start (the
|
|
56
|
+
* process is full, or its project is), so a new request that can start
|
|
57
|
+
* never overtakes one that could have.
|
|
58
|
+
*/
|
|
59
|
+
this.waiting = [];
|
|
60
|
+
}
|
|
61
|
+
/*
|
|
62
|
+
* Runs `work` once a slot for `projectId` is free, and frees it when the
|
|
63
|
+
* work settles, however it settles. Throws TooManyRequestsException
|
|
64
|
+
* without running `work` when the queue is full or the wait too long, and
|
|
65
|
+
* TopologyRequestAbandonedError without running it when `signal` fires
|
|
66
|
+
* first (a read that has started runs to completion).
|
|
67
|
+
*/
|
|
68
|
+
async run(projectId, work, signal) {
|
|
69
|
+
await this.acquire(projectId, signal);
|
|
70
|
+
try {
|
|
71
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
72
|
+
throw new TopologyRequestAbandonedError();
|
|
73
|
+
}
|
|
74
|
+
return await work();
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
this.release(projectId);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
runningCount(projectId) {
|
|
81
|
+
if (projectId === undefined) {
|
|
82
|
+
return this.running;
|
|
83
|
+
}
|
|
84
|
+
return this.runningByProject.get(projectId) || 0;
|
|
85
|
+
}
|
|
86
|
+
waitingCount(projectId) {
|
|
87
|
+
if (projectId === undefined) {
|
|
88
|
+
return this.waiting.length;
|
|
89
|
+
}
|
|
90
|
+
return this.waiting.filter((waiter) => {
|
|
91
|
+
return waiter.projectId === projectId;
|
|
92
|
+
}).length;
|
|
93
|
+
}
|
|
94
|
+
canStart(projectId) {
|
|
95
|
+
return (this.running < this.limits.maxRunning &&
|
|
96
|
+
this.runningCount(projectId) < this.limits.maxRunningPerProject);
|
|
97
|
+
}
|
|
98
|
+
take(projectId) {
|
|
99
|
+
this.running++;
|
|
100
|
+
this.runningByProject.set(projectId, this.runningCount(projectId) + 1);
|
|
101
|
+
}
|
|
102
|
+
acquire(projectId, signal) {
|
|
103
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
104
|
+
return Promise.reject(new TopologyRequestAbandonedError());
|
|
105
|
+
}
|
|
106
|
+
if (this.canStart(projectId)) {
|
|
107
|
+
this.take(projectId);
|
|
108
|
+
return Promise.resolve();
|
|
109
|
+
}
|
|
110
|
+
if (this.waiting.length >= this.limits.maxWaiting ||
|
|
111
|
+
this.waitingCount(projectId) >= this.limits.maxWaitingPerProject) {
|
|
112
|
+
return Promise.reject(new TooManyRequestsException(TOPOLOGY_BUSY_MESSAGE));
|
|
113
|
+
}
|
|
114
|
+
return new Promise((resolve, reject) => {
|
|
115
|
+
/* Leaves the queue (if still in it) and rejects with `error`. */
|
|
116
|
+
const leave = (error) => {
|
|
117
|
+
const index = this.waiting.indexOf(waiter);
|
|
118
|
+
if (index >= 0) {
|
|
119
|
+
this.waiting.splice(index, 1);
|
|
120
|
+
waiter.detach();
|
|
121
|
+
reject(error);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const onAbort = () => {
|
|
125
|
+
leave(new TopologyRequestAbandonedError());
|
|
126
|
+
};
|
|
127
|
+
const waiter = {
|
|
128
|
+
projectId,
|
|
129
|
+
start: resolve,
|
|
130
|
+
timer: null,
|
|
131
|
+
detach: () => {
|
|
132
|
+
if (waiter.timer) {
|
|
133
|
+
clearTimeout(waiter.timer);
|
|
134
|
+
}
|
|
135
|
+
signal === null || signal === void 0 ? void 0 : signal.removeEventListener("abort", onAbort);
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
if (Number.isFinite(this.limits.maxWaitMs)) {
|
|
139
|
+
waiter.timer = setTimeout(() => {
|
|
140
|
+
leave(new TooManyRequestsException(TOPOLOGY_BUSY_MESSAGE));
|
|
141
|
+
}, this.limits.maxWaitMs);
|
|
142
|
+
}
|
|
143
|
+
signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", onAbort);
|
|
144
|
+
this.waiting.push(waiter);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
release(projectId) {
|
|
148
|
+
this.running--;
|
|
149
|
+
const remaining = this.runningCount(projectId) - 1;
|
|
150
|
+
if (remaining > 0) {
|
|
151
|
+
this.runningByProject.set(projectId, remaining);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
this.runningByProject.delete(projectId);
|
|
155
|
+
}
|
|
156
|
+
this.startWaiters();
|
|
157
|
+
}
|
|
158
|
+
/* Hands free slots to waiters in arrival order, skipping full projects. */
|
|
159
|
+
startWaiters() {
|
|
160
|
+
if (this.waiting.length === 0) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const stillWaiting = [];
|
|
164
|
+
for (const waiter of this.waiting) {
|
|
165
|
+
if (this.canStart(waiter.projectId)) {
|
|
166
|
+
this.take(waiter.projectId);
|
|
167
|
+
waiter.detach();
|
|
168
|
+
waiter.start();
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
stillWaiting.push(waiter);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
this.waiting = stillWaiting;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
export default new TopologyConcurrencyLimiter();
|
|
178
|
+
//# sourceMappingURL=TopologyConcurrencyLimiter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopologyConcurrencyLimiter.js","sourceRoot":"","sources":["../../../../../Server/Utils/Topology/TopologyConcurrencyLimiter.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,MAAM,mDAAmD,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAChC,sDAAsD,CAAC;AAEzD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,iCAAiC,GAAW,CAAC,CAAC;AAe3D,MAAM,CAAC,MAAM,2BAA2B,GAA8B;IACpE,UAAU,EAAE,CAAC;IACb,oBAAoB,EAAE,CAAC;IACvB,UAAU,EAAE,EAAE;IACd,oBAAoB,EAAE,EAAE;IACxB,SAAS,EAAE,KAAM;CAClB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACtD;QACE,KAAK,CAAC,mDAAmD,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF;AASD,MAAM,OAAO,0BAA0B;IAUrC,YACU,SAAoC,2BAA2B;QAA/D,WAAM,GAAN,MAAM,CAAyD;QAVjE,YAAO,GAAW,CAAC,CAAC;QACpB,qBAAgB,GAAwB,IAAI,GAAG,EAAkB,CAAC;QAC1E;;;;WAIG;QACK,YAAO,GAAkB,EAAE,CAAC;IAIjC,CAAC;IAEJ;;;;;;OAMG;IACI,KAAK,CAAC,GAAG,CACd,SAAiB,EACjB,IAAsB,EACtB,MAAgC;QAEhC,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC;YACH,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,6BAA6B,EAAE,CAAC;YAC5C,CAAC;YACD,OAAO,MAAM,IAAI,EAAE,CAAC;QACtB,C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