aws / aws-lambda-nodejs-runtime-interface-client

Apache License 2.0
180 stars 56 forks source link

Create initializeFunction lifecycle hook #25

Open dancfox opened 3 years ago

dancfox commented 3 years ago

Add initialization lifecycle hook to UserFunction. This hook is an asynchronous function that honors the await keyword and enables customers to guarantee the completion of async initialization function calls prior to invocation. The lifecycle hook is run a single time prior to the invocation cycle. It is run during the load process, after require and before the handler.

In this version, the lifecycle hook is named by convention as initializeFunction. A possible enhancement to this feature would be to enable customers to customize the name of their initialization hook. This would improve backwards compatibility with existing customer code by helping to prevent namespace collisions.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.