Created
March 20, 2019 20:46
-
-
Save nason/3f9ca2c1626d0da7882fc09cf7af6ac4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.`; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment