chore: support for multiple lifecycles defined by the user #1037
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
In this PR we are updating the lifecycle field of the container request to accept an array of lifecycles structs.
With this in mind, a user could define custom lifecycles to be appended to the list of container lifecycles, which the library will execute in the order they are passed.
Therefore, given two lifecycles in a container request this will be the execution order:
1.1 pre-create
1.2 post-create
1.3 pre-start
1.4 post-start
1.5 pre-stop
1.6 post-stop
1.7 pre-terminate
1.8 post-terminate
2.1 pre-create
2.2 post-create
2.3 pre-start
2.4 post-start
2.5 pre-stop
2.6 post-stop
2.7 pre-terminate
2.8 post-terminate
Besides that, we are refactoring library code to wrap into into functions to leverage the lifecycle, injecting them at the right lifecycle event:
Finally, we are providing with a default logger hook, which leverages the internal logger of the container to print out messages on each lifecycle hook.
Why is it important?
Support for multiple lifecycle hook that could be decoupled from the library, and provide a simple to use manner of logging the events.
Examples: a lifecycle that sends OpenTelemetry traces.
Related issues