exports.handler = function()

in infrastructure/function/src/metadataStreamingLambdaFunction/index.js [16:37]


exports.handler = function (event, context) {
    console.log("event ", JSON.stringify(event));
    const response = {
      statusCode: 200,
      body: JSON.stringify('Succeed'),
    };
    const detail = event.detail;
    const transactionId = detail.transactionId;

    if(detail.streamingStatus === 'STARTED') {
        postDocumentToES(esIndex, detail, transactionId, context);
    }
    
    if(detail.streamingStatus === 'ENDED') {
        // Only endTime needs to be updated for the document of the call.
        const payload = {
            "script": `ctx._source.endTime = '${detail.endTime}'`
        }
        postDocumentToES(esUpdate, payload, transactionId, context);
    }
    return response;
};