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

Improve post save event notification performance #2266

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,27 @@ export const sendReactiveEvent: ReactiveEventDispatcher = async (event) => {

const errors: any[] = []

await Promise.all(
connectionIdsResult.map(({ connectionId }: { connectionId: string }) =>
invokeFunction({
Region: process.env.AWS_REGION as string,
FunctionName: process.env.RESOLVE_WEBSOCKET_LAMBDA_ARN as string,
Payload: {
type: 'send',
connectionId,
data: {
type: 'events',
payload: {
events: [event],
},
},
},
}).catch(errorBoundary(errors))
)
const connectionIds = connectionIdsResult.map(
({ connectionId }: { connectionId: string }) => connectionId
)

await invokeFunction({
Region: process.env.AWS_REGION as string,
FunctionName: process.env.RESOLVE_WEBSOCKET_LAMBDA_ARN as string,
InvocationType: 'RequestOnly',
MaximumExecutionDuration: 200,
Payload: {
type: 'send',
connectionIds,
data: {
type: 'events',
payload: {
events: [event],
},
},
},
}).catch(errorBoundary(errors))

if (errors.length > 0) {
log.warn(`Failed push event to websocket. ${errors}`)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const handleWebsocketEvent = async (
FunctionName: websocketLambdaArn,
Payload: {
type: 'send',
connectionId,
connectionIds: [connectionId],
data: {
type: 'pullEvents',
requestId,
Expand Down