how data lambda invoked event calling function?
essentially lambda function have is:
exports.handler = function(event, context, callback) { var data = {}; data.foo ='hello'; callback(null, data) }
and invoking function looks this:
var aws = require('aws-sdk'); var lambda = new aws.lambda(); var params = { functionname: 'somefunction', invocationtype: 'event' }; lambda.invoke(params, function (err, data) { if (err) { console.log(err, err.stack); // error occurred } else { console.log(json.stringify(data, null, 2)); } });
however thing function is
{ "statuscode": 202, "payload": "" }
i thought point of callback parameter allow invoking function data when function has finished. using wrong or asking not possible lambdas?
when invoke lambda function need set invocationtype
'requestresponse'
instead of 'event'
.
when using event
type callback invoked when payload has been received aws's servers. when using requestresponse
type callback invoked after lambda function has completed , receive data provided callback. not possible want event
type.
Comments
Post a Comment