-
Notifications
You must be signed in to change notification settings - Fork 113
[RFC] Drop event label from handle methods in LambdaHandlers #225
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
Conversation
ac9dc0c
to
501bc6e
Compare
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 |
5104f27
to
3e1d7bb
Compare
@tomerd Updated the name of the event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
some CI failures, seems like some test code needs to be further adjusted |
3e1d7bb
to
8f39837
Compare
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.