Skip to content

Commit

Permalink
Use child process and worker threads only with nodejs runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Sep 10, 2019
1 parent a99e123 commit 963f497
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/lambda/handler-runner/HandlerRunner.js
Expand Up @@ -18,23 +18,6 @@ export default class HandlerRunner {
async _loadRunner() {
const { useChildProcesses, useWorkerThreads } = this._options

if (useWorkerThreads) {
// worker threads
this._verifyWorkerThreadCompatibility()

const { default: WorkerThreadRunner } = await import(
'./WorkerThreadRunner.js'
)
return new WorkerThreadRunner(this._funOptions, this._env)
}

if (useChildProcesses) {
const { default: ChildProcessRunner } = await import(
'./ChildProcessRunner.js'
)
return new ChildProcessRunner(this._funOptions, this._env)
}

const {
functionName,
handlerName,
Expand All @@ -46,6 +29,23 @@ export default class HandlerRunner {
debugLog(`Loading handler... (${handlerPath})`)

if (supportedNodejs.has(runtime)) {
if (useChildProcesses) {
const { default: ChildProcessRunner } = await import(
'./ChildProcessRunner.js'
)
return new ChildProcessRunner(this._funOptions, this._env)
}

if (useWorkerThreads) {
// worker threads
this._verifyWorkerThreadCompatibility()

const { default: WorkerThreadRunner } = await import(
'./WorkerThreadRunner.js'
)
return new WorkerThreadRunner(this._funOptions, this._env)
}

const { default: InProcessRunner } = await import('./InProcessRunner.js')
return new InProcessRunner(
functionName,
Expand Down

0 comments on commit 963f497

Please sign in to comment.