Add initializer with LambdaHandler directly with Decodable event and Void output #589
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add convenience initializer for
LambdaRuntimeto acceptLambdaHandlerinstances withVoidoutputMotivation:
Following PR #581, which added convenience initializers for
LambdaRuntimeto acceptLambdaHandlerinstances withEncodableoutputs, there was still a gap for handlers that returnVoid. This is useful, for example, for AWS event sources like SQS, where theAWSLambdaEventspackage providesSQSEventbut there's no corresponding output type - handlers simply process messages and returnVoid.Without this initializer, developers had to manually wrap their handlers with
LambdaCodableAdapterandLambdaHandlerAdapter, which was verbose and inconsistent with the new API (similar to what is described in #581)Modifications:
Added a new
init(decoder:handler:)convenience initializer toLambdaCodableAdapterinLambda+JSON.swiftthat accepts aJSONDecoderfor handlers withVoidoutput.Added a new convenience initializer to
LambdaRuntimethat accepts aLambdaHandlerinstance withVoidoutput directly, handling the wrapping internally.Updated documentation comments to distinguish between handlers with
VoidandEncodableoutputs.Result:
Developers can now initialize
LambdaRuntimewith handlers that returnVoidusing a clean, direct API. This is especially useful for event sources like SQS:This provides API completeness, matching the convenience initializers for handlers with
Encodableoutputs, and delivers better ergonomics for common serverless patterns.