-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from mriccia/onlycoldstarts
Add parameter to power-tune only cold starts
- Loading branch information
Showing
21 changed files
with
1,121 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
const utils = require('./utils'); | ||
|
||
|
||
module.exports.handler = async(event, context) => { | ||
const {lambdaConfigurations, currConfig, lambdaARN} = validateInputs(event); | ||
const currentIterator = lambdaConfigurations.iterator; | ||
// publish version & assign alias (if present) | ||
await utils.createPowerConfiguration(lambdaARN, currConfig.powerValue, currConfig.alias, currConfig.description); | ||
|
||
const result = { | ||
powerValues: lambdaConfigurations.powerValues, | ||
initConfigurations: lambdaConfigurations.initConfigurations, | ||
iterator: { | ||
index: (currentIterator.index + 1), | ||
count: currentIterator.count, | ||
continue: ((currentIterator.index + 1) < currentIterator.count), | ||
}, | ||
}; | ||
|
||
if (!result.iterator.continue) { | ||
// clean the list of configuration if we're done iterating | ||
delete result.initConfigurations; | ||
} | ||
|
||
return result; | ||
}; | ||
function validateInputs(event) { | ||
if (!event.lambdaARN) { | ||
throw new Error('Missing or empty lambdaARN'); | ||
} | ||
const lambdaARN = event.lambdaARN; | ||
if (!(event.lambdaConfigurations && event.lambdaConfigurations.iterator && event.lambdaConfigurations.initConfigurations)){ | ||
throw new Error('Invalid iterator for initialization'); | ||
} | ||
const iterator = event.lambdaConfigurations.iterator; | ||
if (!(iterator.index >= 0 && iterator.index < iterator.count)){ | ||
throw new Error(`Invalid iterator index: ${iterator.index}`); | ||
} | ||
const lambdaConfigurations = event.lambdaConfigurations; | ||
const currIdx = iterator.index; | ||
const currConfig = lambdaConfigurations.initConfigurations[currIdx]; | ||
if (!(currConfig && currConfig.powerValue)){ | ||
throw new Error(`Invalid init configuration: ${JSON.stringify(currConfig)}`); | ||
} | ||
return {lambdaConfigurations, currConfig, lambdaARN}; | ||
} |
Oops, something went wrong.