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

ASGI Extension support #78

Closed
synodriver opened this issue May 25, 2023 · 9 comments
Closed

ASGI Extension support #78

synodriver opened this issue May 25, 2023 · 9 comments

Comments

@synodriver
Copy link

Great project!Just out of curious, is there any ASGI Extension support in plan?

@gi0baro
Copy link
Member

gi0baro commented May 25, 2023

@synodriver thank you!

Regarding ASGI extensions, at the moment there are no plans; at least not within the next milestones.
Do you have any specific need/use-case?

@synodriver
Copy link
Author

Some asgi frameworks use zerocopy extension to serve static files, which can significantly improve the performance, and in some cases the server need to talk to a grpc client directly, which need the trailer header extension. I just forked hypercorn to add all extension support, this may help implementing these extensions for the rust server.

@gi0baro
Copy link
Member

gi0baro commented May 25, 2023

So, regarding the two explicit extensions you mentioned:

  • due to Granian architecture the zerocopy extension won't be feasible. Since it is based on file-descriptors, I'm 99% sure it won't be possible to make that descriptor available in a non-blocking and safe fashion to the tokio runtime granian uses behind the scenes
  • regarding trailers, there might be a chance to make 'em work revising the actual ASGI protocol implementation, but since hyper doesn't support them on HTTP/1.1 (Sending HTTP/1.1 trailers hyperium/hyper#2719), they would work only on http2

@synodriver
Copy link
Author

Thanks for letting me know that since I'm not very familiar with rust. Looks like the asgi spec itself heavily relies on python asyncio implementation, making other languages very hard to implement.

@gi0baro
Copy link
Member

gi0baro commented May 25, 2023

Looks like the asgi spec itself heavily relies on python asyncio implementation, making other languages very hard to implement.

Yep. It's even in the first paragraph of RSGI rationale (https://github.com/emmett-framework/granian/blob/master/docs/spec/RSGI.md#rationale) ;)

@synodriver
Copy link
Author

So regardless thoses extension which is difficult to support, what about other extensions mentioned in asgi spec? Are they possible for the rust server?BTW the easiest extension to implement I think should be lifespan.state, just pass an empty dict to scope is ok, and starlette have already take use of it.

@gi0baro
Copy link
Member

gi0baro commented May 29, 2023

@synodriver sorry for the late reply, I was in PyConIT this weekend and a lot was happening!

I agree lifespan.state would be the easiest and quicker to implement!
Regarding all the others, maybe we can just put together the complete list and for each of them I can tell if feasible or not :)

@synodriver
Copy link
Author

I agree too. Actually I have send a pr to nginx unit to add lifespan.state support. It was a C project which I can handle, but unfortunately I'm not familiar with rust =(

@gi0baro
Copy link
Member

gi0baro commented Jun 26, 2023

This is now tracked in #93 and #94

@gi0baro gi0baro closed this as completed Jun 26, 2023
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

No branches or pull requests

2 participants