Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add json field #31

Merged
merged 4 commits into from
Sep 23, 2020
Merged

Add json field #31

merged 4 commits into from
Sep 23, 2020

Conversation

shawn-cx-li
Copy link
Contributor

@shawn-cx-li shawn-cx-li commented Sep 23, 2020

  • return only the first element of Records for S3 events
  • add json field, when publish message it will be stringified, then parsed back to json when consume the message
  • add limitation of maximum 256KB message so we can catch the error if json filed is too large

@@ -7,6 +7,9 @@ const sns = new AWS.SNS({
region: process.env.AWS_SNS_REGION
});

// Amazon SNS currently allows a maximum size of 256 KB for published messages.
const MAX_EVENT_MESSAGE_SIZE = 256 * 1024;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you multiply by 1024?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's 256 kilobyte limitation, so MAX_EVENT_MESSAGE_SIZE means the maximum bytes we can have

index.js Outdated
@@ -115,6 +134,13 @@ function dispatch({ type, uri, id, checksum, source, message }) {
throw new InvalidEventMessageError("event message is required");
}

let JsonStr;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe lowercase jsonStr because it is not a class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the pick up, fixed

@shawn-cx-li shawn-cx-li merged commit 71d9b61 into master Sep 23, 2020
@shawn-cx-li shawn-cx-li deleted the add-json-field branch September 23, 2020 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant