Closed fabianfett closed 2 years ago
This change makes sense. It'll cause some annoyance as it changes the signature of a protocol requirement but I can live with that.
From a different perspective in all the lambda docs we do refer to the object being passed to lambda as the event. If you lack familiarity with aws and swift runtime is your first encounter removing the label could be confusing for some people. Just another thought here...
The word event is used for example in this doc several times even in reference to an api gateway request: https://docs.aws.amazon.com/lambda/latest/dg/lambda-services.html
cc @bmoffatt
it is the "swift way" to drop label on first arguments when their meaning / usage can be easily inferred from the method name or the general context. I dont have a strong opinion here (there are two sides to this coin, as @kneekey23 points out), and in any case we should use the term "event" in the API docs to connect it back to the AWS terminology, even if we dont have a label
@swift-server-bot test this please
@tomerd Updated the name of the event In
type to Event
. Out
is now called Output
. This should make adoption even easier. Please re-review.
some CI failures, seems like some test code needs to be further adjusted
Drop event label from handle methods in LambdaHandlers protocols
Motivation:
In Lambda functions user's handle events from different sources. Those events can be
S3Event
s, but alsoAPIGatewayRequest
s. Let's look at a Lambda, that integrates with APIGateway.The argument in the
handle
method is labeledevent
even though, in this caserequest
would be clearly a better name. The user could userequest
as a parameter name by explicitly specifying the parameter name:However
event request
is not easy to read and the parameter name overwrite is not the most known swift feature. For this reason I would advice against this option.For this reason I propose dropping the argument label and specifying a parameter name
event
to guide users. New function signature:This would allow users to write lambdas, that integrate with APIGateway as such:
Modifications:
event
label in thehandle
LambdaHandler protocol methodsEventLoopHandler
protocol toEvent
andOutput
(fromIn
andOut
)Result:
A cleaner, more flexible API.