現在、RDS DBを呼び出してアイテムのリストを取得しています。これらのアイテムをループして各アイテムのPOST呼び出しを行います。私の質問は次のとおりです:AWSラムダメソッドを使用してリストをループし、複数の他のラムダメソッドを呼び出す
このリストをループし、リスト内の各項目に対して別のラムダ関数を呼び出すことは可能ですか?理想的には、これは応答を待つことではなく、他のものを呼び出すことを続けます。呼び出された各メソッドは、完了するまで実行を継続します。構造であり、これはここでNodeJs 6.10
に基づいされますのでご注意ください。
var pg = require('knex')({
client: 'pg',
connection: process.env.DATABASE_URL,
debug: true
});
// Internal
const time = require('./lib/time');
const response = require('./lib/response');
const helpers = require('./lib/helpers');
module.exports.createBatch = (event, context, cb) => {
// Lambda settings
context.callbackWaitsForEmptyEventLoop = false;
const now = time.getCurrentTime();
pg('table')
.join('table')
.select('*')
.then(function(rows) {
return rows;
})
.then(function(rows) {
console.log('rows: ' + rows);
let count = 0;
if (!_.isEmpty(rows)) {
for(let row of rows) {
// ****
// CALL OTHER LAMBDA FUNCTION HERE
// ****
axios.post(row)
.then(function (res) {
// ****
// MOVE THIS POST CALL INTO ANOTHER LAMBDA FUNCTION
// ****
})
}
}
})
aws-sdkはラムダ呼び出しメソッド – bryan60