Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin middleware revamp #2550

Merged
merged 13 commits into from Sep 21, 2022
Merged

Begin middleware revamp #2550

merged 13 commits into from Sep 21, 2022

Conversation

ahopkins
Copy link
Member

@ahopkins ahopkins commented Sep 20, 2022

#2521 is a bit too ambitious, and really is a bit of scope creep. This PR is meant to obtain the benefits of middleware streamlining and up front assignment without adding the complexity of a new request handling mechanism.


This PR aims to:

  • introduce an API to control middleware ordering
  • performance boost
@app.on_request(priority=99)
async def high_priority(request):
    ...

@ahopkins ahopkins marked this pull request as ready for review September 21, 2022 07:01
@ahopkins ahopkins requested review from a team as code owners September 21, 2022 07:01
@ahopkins ahopkins mentioned this pull request Sep 21, 2022
@codecov
Copy link

codecov bot commented Sep 21, 2022

Codecov Report

Base: 88.430% // Head: 88.479% // Increases project coverage by +0.048% 🎉

Coverage data is based on head (2c41fc5) compared to base (43ba381).
Patch coverage: 94.736% of modified lines in pull request are covered.

Additional details and impacted files
@@              Coverage Diff              @@
##              main     #2550       +/-   ##
=============================================
+ Coverage   88.430%   88.479%   +0.048%     
=============================================
  Files           78        79        +1     
  Lines         6474      6536       +62     
  Branches      1246      1251        +5     
=============================================
+ Hits          5725      5783       +58     
- Misses         517       521        +4     
  Partials       232       232               
Impacted Files Coverage Δ
sanic/http/http1.py 84.827% <75.000%> (-0.384%) ⬇️
sanic/request.py 94.458% <77.777%> (-0.427%) ⬇️
sanic/middleware.py 96.774% <96.774%> (ø)
sanic/app.py 88.224% <100.000%> (+0.020%) ⬆️
sanic/asgi.py 90.163% <100.000%> (+0.247%) ⬆️
sanic/mixins/middleware.py 100.000% <100.000%> (ø)
sanic/worker/inspector.py 98.850% <100.000%> (+0.013%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

prryplatypus
prryplatypus previously approved these changes Sep 21, 2022
sanic/app.py Show resolved Hide resolved
sanic/app.py Show resolved Hide resolved
@ahopkins ahopkins merged commit 6e32270 into main Sep 21, 2022
@ahopkins ahopkins deleted the middleware-revamp-redux branch September 21, 2022 21:43
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.

None yet

2 participants