Skip to content

Feature request: Expose Response Streaming in Event Handler Public API #4726

@svozza

Description

@svozza

Use case

We have added added streaming functionality back in #4476 but didn't expose it because we didn't support function URLs. With the merging of #4714 we now support this lambda integration so should make it available for use.

Solution/User Experience

We should expose a healper function that will turn a router into a stream compatible lambda handler:

export const handler = streamify(app)

This will just be a wrapper around the built in lambda stream function that the lambda run time provides:

function streamify(app: Router) {
  return awslambda.streamifyResponse(async (event, responseStream, context) => {
    const res = await app.resolveStream(convertV2ToV1(event), context, {responseStream});
    console.log(res)
  })
}

Not we also need to provide a fallback for the awslambda.streamifyResponse global so that our unit tests will work. All the streaming unit tests will also need to be updated to use the helper function.

Alternative solutions

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedevent-handlerThis item relates to the Event Handler Utilityfeature-requestThis item refers to a feature request for an existing or new utility

Type

No type

Projects

Status

Coming soon

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions