swift-aws-lambda-runtime icon indicating copy to clipboard operation
swift-aws-lambda-runtime copied to clipboard

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

Open tomerd opened this issue 3 years ago • 6 comments

motivation: make simple things simple

changes:

  • add new abstraction names SimpleLambdaHandler that has a default initializer
  • add test

tomerd avatar Apr 15 '22 18:04 tomerd

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

tomerd avatar Apr 15 '22 18:04 tomerd

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).

stevapple avatar Apr 15 '22 18:04 stevapple

@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.

tomerd avatar Apr 15 '22 19:04 tomerd

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.

stevapple avatar Apr 15 '22 19:04 stevapple

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 avatar Apr 15 '22 21:04 tomerd

superseded by #273

tomerd avatar Oct 08 '22 00:10 tomerd