swift-server / swift-aws-lambda-runtime

Swift implementation of AWS Lambda Runtime
Apache License 2.0
1.12k stars 101 forks source link

add new abstraction for simple Lambda that does not need explicit initialization #259

Closed tomerd closed 1 year ago

tomerd commented 2 years ago

motivation: make simple things simple

changes:

tomerd commented 2 years ago

we could / should consider doing this on LambdaHander instead of the new abstraction, also not in love with the "Simple" prefix.

stevapple commented 2 years ago

We can drop context: from LambdaHandler’s initializer, then the SimpleLambdaHandler model will just fit (we can keep async and throws so users can still initialize some resources if they want).

tomerd commented 2 years ago

@stevapple context is needed when users need to initialize resources, it provides thinks like NIO's EventLoop and Terminator, so we cannot just drop it.

stevapple commented 2 years ago

Is there any reason they cannot use async/await for asynchronous startup, and use throw in place of manual termination? I think that's the "simple" way and should work for most people.

tomerd commented 2 years ago

termination is for resource cleanup when shutting down, there needs to be an entry point to that. also all NIO based clients (eg db client based on NIO) need access the the EventLoop for initialization to avoid thread hops

tomerd commented 1 year ago

superseded by #273