jeudi 4 juin 2015

AWS Lambda: Can I return context and have a task still running?

Right now I have a lambda function in production that processes log strings and then return them to the client, so:

1) string received by lambda
2) lambda transforms string
3) lambda returns via context.succeed the transformed string 

Now I am adding an additional step that will save the string in a dynamodb table, so the workflow will be:

1) string received by lambda
2) lambda transforms string
3) lambda saves string to dynamo 
4) lambda returns via context.succeed the transformed string 

Right now the bit the saves the function is something like:

function _saveItem (item) {
    dynamo.putItem(item, function (err, data) {
        //error handling here
        context.succeed(JSON.stringify(item));
    })
}

I'd like to know if it's somehow possible to fire the putItem function and, without waiting for it to end, return the item via context.succeed




Aucun commentaire:

Enregistrer un commentaire