Skip to content

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Mar 9, 2020

alternative to #24

@tomerd tomerd requested review from glbrntt and fabianfett March 9, 2020 21:42
@tomerd tomerd mentioned this pull request Mar 9, 2020
@tomerd tomerd force-pushed the refactor-init-2 branch 6 times, most recently from 9678b53 to 4727ed1 Compare March 10, 2020 03:47
Copy link
Contributor

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this approach much more than #24 -- looks great.

Copy link
Member

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm good with this now! Some nits before we merge, but I think we are on a good trajectory.

///
/// - note: This is a blocking operation that will run forever, as it's lifecycle is managed by the AWS Lambda Runtime Engine.
@inlinable
public static func run(_ factory: @escaping LambdaHandlerFactory) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we use a typealias LambdaHandlerFactory

I would guess we will also offer just a handler closure option. Do we want to name those run() {} and the factory closures functions like this one createHandlerAndRun() {}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally like the shorter name but can consider makeAndRun in a different PR?

///
/// - note: This is a blocking operation that will run forever, as it's lifecycle is managed by the AWS Lambda Runtime Engine.
@inlinable
public static func run(_ factory: @escaping (EventLoop) throws -> LambdaHandler) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we don't use a typealias.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's because its used in much less place and not user facing, typically you would pass in a ctor here

Copy link
Contributor Author

@tomerd tomerd Mar 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally like the shorter name but can consider makeAndRun in a different PR? wrong comment

@@ -113,31 +150,33 @@ public enum Lambda {
private let eventLoop: EventLoop
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should move this Lambda.Lifecycle into another file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do in another PR

tomerd added 8 commits March 10, 2020 11:04
motivation: make initialization logic more robust, allowing setup at contructor time and also async bootstrap

changes:
* break apart "initialization" into two parts:
  * optional throwing constructor (provider) that takes an EventLoop
  * optional BootstrappedLambdaHandler protocol that takes an EventLoop and returns async
* update core API and logic to support new initialization logic
* add tests to various initialization flows
motivation: make initialization logic more robust, allowing setup at contructor time and also async bootstrap

changes:
* break apart "initialization" into two parts:
  * optional throwing constructor (provider) that takes an EventLoop
  * optional BootstrappedLambdaHandler protocol that takes an EventLoop and returns async
* update core API and logic to support new initialization logic
* add tests to various initialization flows
@tomerd tomerd merged commit a051851 into master Mar 10, 2020
@tomerd tomerd deleted the refactor-init-2 branch March 10, 2020 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants