hummingbird-project / hummingbird-lambda

Hummingbird running inside an AWS Lambda
Apache License 2.0
24 stars 3 forks source link

Make LambdaInitializationContext available in HBLambda (2.0) #17

Closed sliemeobn closed 8 months ago

sliemeobn commented 8 months ago

Currently, neither the init nor the buildResponder has access to the LambdaInitializationContext.

If we add it as a parameter to HBLambda.init we can use things like logger or eventLoop when setting up other components.

adam-fowler commented 8 months ago

What's your thoughts @Joannis pass it to the init or into buildResponder.

To me the init is clearer but then we'll require every HBLamba to implement init(context:) and store anything they create from it in HBLambda.

Passing it to buildResponder doesn't feel right. It is the InitializationContext after all. But it might make users lives simpler, in that, it is where you build your responder and need references to all the services you are going to use.

sliemeobn commented 8 months ago

Thought from my side: If you want to use shutdown to tear things down, the initializer will be much nicer, because you can use simple let fields on the lambda struct.

If you can only set things up in the buildResponder, it will have to be a var myTing: Thing? dance.

Joannis commented 8 months ago

I agree with the points thus far, I vouch for adding it to init(context:)

adam-fowler commented 8 months ago

18