recursive-lambda
recursive-lambda is a wrapper around recursive code called within AWS Lambda. It solves the problem of running out of execution time.
Should a lambda hit the time limit, it will invoke new lambda so it could carry on with its business.
Example
import Promise from 'bluebird';
import { SimpleStatefulRecursiveService } from 'recursive-lambda';
class ExampleRecursiveService extends SimpleStatefulRecursiveService {
constructor(params, lambdaClient, context) {
super(params, lambdaClient, context);
this.initState({executionCount: 0});
}
action(params = {}) {
return this.exampleEnigmaticRecursiveFunction(params);
}
get executionInvariant() {
return this.state.executionCount < 4;
}
get executionThreshold() {
return 200000;
}
exampleEnigmaticRecursiveFunction(params = {}) {
return new Promise((resolve, reject) => {
const executionCount = this.state.executionCount + 1;
this.updateState({executionCount, result: 'accumulated dummy result'});
resolve();
});
}
}
Contributing
Contributions are always welcome!
Developed by [microapps] (http://microapps.com/?utm_source=recursive-lambda-repo-readme&utm_medium=click&utm_campaign=github)
Used in our live products: [MoonMail] (https://moonmail.io/?utm_source=recursive-lambda-repo-readme&utm_medium=click&utm_campaign=github) & [MONEI] (https://monei.net/?utm_source=recursive-lambda-repo-readme&utm_medium=click&utm_campaign=github)
License
recursive-lambda is available under the MIT license. See the LICENSE file for more info.