-
Notifications
You must be signed in to change notification settings - Fork 118
Lambda factory as a protocol requirement. #244
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
| /// - parameters: | ||
| /// - factory: A `ByteBufferLambdaHandler` factory. | ||
| /// | ||
| /// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine. |
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.
update docs ^^
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.
fixed
| /// - factory: A `ByteBufferLambdaHandler` factory. | ||
| /// | ||
| /// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine. | ||
| internal static func run<Handler: ByteBufferLambdaHandler>(configuration: Configuration = .init(), handlerType: Handler.Type) -> Result<Int, Error> { |
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.
is handlerType used?
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.
I guess needed for the generics?
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.
Yes. It is there to make the user declare the Generic type. Otherwise the user would need to write:
Lambda.run<Handler>()| /// connections and HTTP clients for example. It is encouraged to use the given `EventLoop`'s conformance | ||
| /// to `EventLoopGroup` when initializing NIO dependencies. This will improve overall performance, as it | ||
| /// minimizes thread hopping. | ||
| static func factory(context: Lambda.InitializationContext) -> EventLoopFuture<Self> |
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.
maybe makeHandler or makeInstance? factory is generally not popular term in Swift. cc @weissi for ideas
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.
Yeah, generally "make" is the word to use; makeHandler would work too.
| /// The lambda runtime provides a default implementation of the method that manages the launch | ||
| /// process. | ||
| public static func main() { | ||
| _ = Lambda.run(configuration: .init(), handlerType: Self.self) |
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.
should we mark Lambda::run @discardableResult?
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.
I think the Lambda.run method should not return anything. But I haven't made my mind up about this fully. Would like to tackle later.
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.
nice! some small suggestions
As previously discussed...
We want to use the same lambda application lifecycle for all lambda implementations. Currently we support
@mainonly for theLambdaHandlerprotocol. This PR brings the@mainfunctionality to the lower level protocols.Modifications:
ByteBufferLambdaHandlerprotocolHandlerFactory) from theLambdaRuntimeandLambdaLambdaRuntimegeneric over theLambdaHandlertypeResult: