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

Add 'native' async app #1534

Closed
RobbeSneyders opened this issue May 10, 2022 · 0 comments · Fixed by #1613
Closed

Add 'native' async app #1534

RobbeSneyders opened this issue May 10, 2022 · 0 comments · Fixed by #1613
Assignees
Milestone

Comments

@RobbeSneyders
Copy link
Member

Next to the synchronous Flask app, we also want to provide an asynchronous app. Instead of implementing an existing async framework, I propose to implement a simple 'native' app. We can implement this app using a combination of low level starlette components and the routing lookup mechanism we already implemented in the middleware.

Instead of using the native app, the connexion middleware can also be applied to existing async frameworks to add connexion functionality.

#1395 for context.

@RobbeSneyders RobbeSneyders added this to the Connexion 3.0 milestone May 10, 2022
@RobbeSneyders RobbeSneyders self-assigned this May 10, 2022
RobbeSneyders added a commit that referenced this issue Dec 28, 2022
Fixes #1534

Changes proposed in this pull request:
- Adds a "native" async app based on lower level Starlette tools. It
leverages the routing already done in the middleware.
- Extracts code related to the parameter decorator out of the Operation
objects

There's some more work to be done, but this PR is already quite huge, so
I wanted to stop at a point where I got all the tests and a simple
example working.
- Still some general refactoring. I left some TODOs, and the Operation
classes are still relied on in too many places.
- Sync routes on an Async app should receive async decorators, so they
can access the body using `await`. The decorators should then run the
sync route in a threadpool to prevent blocking.
- We should be able to reuse the parameter decorator for all ASGI apps
since we're working with a Starlette Request which we can get directly
from the scope and receive channel, which we can make available as
context. This means we'll pass Starlette Datastructures to the view
functions (eg. FormData, UploadFiles, ...), but if this is opt-in, I
don't see any issue with this.
- We should be able to reuse the response parsing for Starlette apps as
well since it returns a StarletteResponse.
- We should test the AsyncApp as well. I'm hoping we can do this quite
quickly by generating a test client for it in the fixtures as well, but
in the long term some more work will be needed.
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 a pull request may close this issue.

1 participant