(workspaceId: string)
| 2267 | } |
| 2268 | |
| 2269 | private async getActiveWorkflowRunIds(workspaceId: string): Promise<Set<string>> { |
| 2270 | assert(workspaceId.length > 0, "getActiveWorkflowRunIds requires workspaceId"); |
| 2271 | const cached = this.activeWorkflowRunIdsByWorkspace.get(workspaceId); |
| 2272 | if (cached != null) { |
| 2273 | const bootstrap = this.activeWorkflowRunIdBootstrapsByWorkspace.get(workspaceId); |
| 2274 | if (bootstrap != null) { |
| 2275 | await bootstrap; |
| 2276 | } |
| 2277 | return cached; |
| 2278 | } |
| 2279 | |
| 2280 | // Install the shared Set before awaiting disk so parallel workflow status events |
| 2281 | // mutate the same cache instead of racing to replace each other after bootstrap. |
| 2282 | const activeRunIds = new Set<string>(); |
| 2283 | this.activeWorkflowRunIdsByWorkspace.set(workspaceId, activeRunIds); |
| 2284 | const bootstrap = this.populateActiveWorkflowRunIds(workspaceId, activeRunIds); |
| 2285 | this.activeWorkflowRunIdBootstrapsByWorkspace.set(workspaceId, bootstrap); |
| 2286 | try { |
| 2287 | return await bootstrap; |
| 2288 | } finally { |
| 2289 | if (this.activeWorkflowRunIdBootstrapsByWorkspace.get(workspaceId) === bootstrap) { |
| 2290 | this.activeWorkflowRunIdBootstrapsByWorkspace.delete(workspaceId); |
| 2291 | } |
| 2292 | } |
| 2293 | } |
| 2294 | |
| 2295 | private async getActiveWorkflowRunCount(workspaceId: string): Promise<number> { |
| 2296 | return (await this.getActiveWorkflowRunIds(workspaceId)).size; |
no test coverage detected