Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function handleInsert(record) {}
- async function handleUpdate(record) {}
- async function handleRemove(record) {}
- async function receiveHandler(event, context, callback) {
- const results = await Promise.all(
- event.Records.map(record => {
- console.log(JSON.stringify(record));
- switch (record.eventName) {
- case 'INSERT':
- return handleInsert(record);
- case 'MODIFY':
- return handleUpdate(record);
- case 'REMOVE':
- return handleRemove(record);
- default:
- console.error('Unknown Event');
- console.log(JSON.stringify(record));
- // Return, not throw, so stream processing continues
- // If an error is thrown from this handler, the event will be retried
- return `Unknown event: ${record.eventName}`;
- }
- })
- );
- console.log(results);
- return `Successfully processed ${event.Records.length} records.`;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement