-
-
Notifications
You must be signed in to change notification settings - Fork 321
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 use_connection hook #823
Conversation
7d2617b
to
fc3f28c
Compare
fc3f28c
to
2b08d63
Compare
@Archmonger to make this work with |
@Archmonger does this look good to you? |
Been pretty busy these last two weeks, haven't had time to do a code review. Hopefully will have time at night during the upcoming weekdays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't go all-in on changing websocket
to carrier
.
The more I think about our reliance on an asyncio running loop, the more impossible it seems for us to use anything other than Websockets.
HTTP
simply doesn't have any decent level of persistence, and it's awkward/unreasonable to make every user run an "IDOM server" separately as a backhaul running loop. I've been debating closing that issue related to this.
Everything else LGTM.
I don't really see any harm in using a generic name like |
I'd like to merge this so I can get started integrating these changes into idom-router. I don't think there's anything that will be impacted if we decide to rename the |
closes: microsoft/playwright-python#819
Rather than having a hook registration framework. All we need in order to solve the problem at hand is to make it possible for each respective backend to use a common context through which they can declare a scope and location. To do this we define a
ConnectionContext
that each backend must activate with aConnection
object. TheConnection
object allows the backend to declare scope, location, and an additional, implementation specific, carrier. The carrier is intended to describe the manner in which a connection is mediated (e.g. an HTTP request or websocket).As a result of these changes, there are now common hooks for the following:
use_connection() -> Connection[Any]
use_scope() -> dict[str, Any]
use_location() -> Location
Backend implementations provide their own
idom.backend.*.use_connection
hooks, but these return the exact same object as the commonidom.use_connection
hook. The only difference is that the type annotation for the return type is narrowed to reflect the carrier of the backend. In narrowing the type though, various backend implementation are also provide implementation specificuse_request
oruse_websocket
hooks.Checklist
Please update this checklist as you complete each item:
changelog.rst
has been updated with any significant changes.