Skip to content

Refactor: Unify lifespan hooks#1663

Merged
provinzkraut merged 3 commits into
mainfrom
unify-lifespan-hooks
May 13, 2023
Merged

Refactor: Unify lifespan hooks#1663
provinzkraut merged 3 commits into
mainfrom
unify-lifespan-hooks

Conversation

@provinzkraut

Copy link
Copy Markdown
Member

Implements #1634, as discussed in #1635.

The following application hooks were removed:

  • before_startup
  • after_startup
  • before_shutdown
  • after_shutdown

The hooks on_startup and on_shutdown have been altered to optionally accept an application instance as their only argument. The decision to keep this detail around was made to more easily allow to re-use existing callables and pass them to the hooks, without having to wrap them in another callable which accepts a positional argument.

In addition, the lifespan argument to Litestar et. al was changed to allow instances of AbstractAsyncContextManager alongside callables which return such context managers. This was done to allow e.g. plugins to inject themselves as a lifespan manager.

@provinzkraut provinzkraut requested a review from a team as a code owner May 13, 2023 10:02
@provinzkraut provinzkraut changed the title Unify lifespan hooks Refactor: Unify lifespan hooks May 13, 2023
@provinzkraut provinzkraut added this to the 2.0 milestone May 13, 2023
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@peterschutt peterschutt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Unify ASGI and application hooks

2 participants