Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. async function handleInsert(record) {}
  2. async function handleUpdate(record) {}
  3. async function handleRemove(record) {}
  4.  
  5. async function receiveHandler(event, context, callback) {
  6. const results = await Promise.all(
  7. event.Records.map(record => {
  8. console.log(JSON.stringify(record));
  9. switch (record.eventName) {
  10. case 'INSERT':
  11. return handleInsert(record);
  12. case 'MODIFY':
  13. return handleUpdate(record);
  14. case 'REMOVE':
  15. return handleRemove(record);
  16. default:
  17. console.error('Unknown Event');
  18. console.log(JSON.stringify(record));
  19. // Return, not throw, so stream processing continues
  20. // If an error is thrown from this handler, the event will be retried
  21. return `Unknown event: ${record.eventName}`;
  22. }
  23. })
  24. );
  25.  
  26. console.log(results);
  27.  
  28. return `Successfully processed ${event.Records.length} records.`;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement