Skip to content

Commit

Permalink
refactor: in-process constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Aug 11, 2022
1 parent 77f71cc commit 12ab4c9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
12 changes: 7 additions & 5 deletions src/lambda/handler-runner/HandlerRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ export default class HandlerRunner {
)

return new InProcessRunner(
functionKey,
{
codeDir,
functionKey,
handler,
servicePath,
timeout,
},
this.#env,
timeout,
handler,
servicePath,
codeDir,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ process.on('message', async (messageData) => {

// TODO we could probably cache this in the module scope?
const inProcessRunner = new InProcessRunner(
functionKey,
{
codeDir,
functionKey,
handler,
servicePath,
timeout,
},
process.env,
timeout,
handler,
servicePath,
codeDir,
)

const result = await inProcessRunner.run(event, context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export default class InProcessRunner {

#timeout = null

constructor(functionKey, env, timeout, handler, servicePath, codeDir) {
constructor(funOptions, env) {
const { codeDir, functionKey, handler, servicePath, timeout } = funOptions

this.#codeDir = codeDir
this.#env = env
this.#functionKey = functionKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ parentPort.on('message', async (messageData) => {

// TODO we could probably cache this in the module scope?
const inProcessRunner = new InProcessRunner(
functionKey,
{
codeDir,
functionKey,
handler,
servicePath,
timeout,
},
env,
timeout,
handler,
servicePath,
codeDir,
)

let result
Expand Down

0 comments on commit 12ab4c9

Please sign in to comment.