Skip to content

Commit

Permalink
Parallel resolve plugin entries
Browse files Browse the repository at this point in the history
Signed-off-by: Doron Nahari <[email protected]>
  • Loading branch information
DoroNahari committed Jan 27, 2020
1 parent 1ca3ec3 commit 5abc81d
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions packages/plugin-ext/src/main/node/plugin-deployer-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ import { injectable, optional, multiInject, inject } from 'inversify';
import {
PluginDeployerResolver, PluginDeployerFileHandler, PluginDeployerDirectoryHandler,
PluginDeployerEntry, PluginDeployer, PluginDeployerResolverInit, PluginDeployerFileHandlerContext,
PluginDeployerDirectoryHandlerContext, PluginDeployerEntryType, PluginDeployerHandler,
PluginDeployerDirectoryHandlerContext, PluginDeployerEntryType, PluginDeployerHandler, PluginDependencies,
} from '../../common/plugin-protocol';
import { PluginDeployerEntryImpl } from './plugin-deployer-entry-impl';
import { PluginDeployerResolverContextImpl, PluginDeployerResolverInitImpl } from './plugin-deployer-resolver-context-impl';
import {
PluginDeployerResolverContextImpl,
PluginDeployerResolverInitImpl
} from './plugin-deployer-resolver-context-impl';
import { ProxyPluginDeployerEntry } from './plugin-deployer-proxy-entry-impl';
import { PluginDeployerFileHandlerContextImpl } from './plugin-deployer-file-handler-context-impl';
import { PluginDeployerDirectoryHandlerContextImpl } from './plugin-deployer-directory-handler-context-impl';
Expand Down Expand Up @@ -112,15 +115,21 @@ export class PluginDeployerImpl implements PluginDeployer {
const visited = new Set<string>();
const pluginsToDeploy = new Map<string, PluginDeployerEntry>();

const queue = [...pluginEntries];
let queue = [...pluginEntries];
while (queue.length) {
const chunk = [];
const dependenciesChunk: PluginDependencies['mapping'][] = [];
const workload: string[] = [];
while (queue.length) {
const current = queue.shift()!;
if (visited.has(current)) {
continue;
} else {
workload.push(current);
}
visited.add(current);
}
queue = [];
await Promise.all(workload.map(async current => {
try {
const pluginDeployerEntries = await this.resolvePlugin(current);
await this.applyFileHandlers(pluginDeployerEntries);
Expand All @@ -130,16 +139,16 @@ export class PluginDeployerImpl implements PluginDeployer {
if (dependencies && !pluginsToDeploy.has(dependencies.metadata.model.id)) {
pluginsToDeploy.set(dependencies.metadata.model.id, deployerEntry);
if (dependencies.mapping) {
chunk.push(dependencies.mapping);
dependenciesChunk.push(dependencies.mapping);
}
}
}
} catch (e) {
console.error(`Failed to resolve plugins from '${current}'`, e);
}
}
for (const dependencies of chunk) {
for (const [dependency, deployableDependency] of dependencies) {
}));
for (const dependencies of dependenciesChunk) {
for (const [dependency, deployableDependency] of dependencies!) {
if (!pluginsToDeploy.has(dependency)) {
queue.push(deployableDependency);
}
Expand Down

0 comments on commit 5abc81d

Please sign in to comment.