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 <doron.nahari@sap.com>
  • Loading branch information
DoroNahari committed Jan 27, 2020
1 parent 1ca3ec3 commit ea82d1b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 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
} 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: Array< Map<string, string>> = [];
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,15 +139,15 @@ 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 dependencies of dependenciesChunk) {
for (const [dependency, deployableDependency] of dependencies) {
if (!pluginsToDeploy.has(dependency)) {
queue.push(deployableDependency);
Expand Down

0 comments on commit ea82d1b

Please sign in to comment.