-
Notifications
You must be signed in to change notification settings - Fork 125
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
API design to get hold of a Tokio handle within a handler #78
Comments
I'm not sure what @smangelsdorf had in mind but I was thinking of something along the lines of passing a handle reference to Line 123 in 953c39b
Line 151 in 953c39b
state .
I may be missing some importance nuance here as I've only very briefly considered this, happy to keep kicking this around if I've overlooked something important. If we do change Line 123 in 953c39b
|
Related: #69 will need access to the event loop as well. |
Tokio was discussing a change which merges both these types into a |
One complicating factor here is that we're creating a Lines 21 to 35 in 953c39b
The structure here might have to change a bit, to have With this small refactor I think your suggestion will work well. 👍 |
Apologies I mis-spoke on this one, please ignore that comment. |
This lays the groundwork for addressing #78 - exposing the `Handle` to Gotham applications.
🎉 😂 💫 💌 📣 |
As discussed on Gitter with @bradleybeddoes, I'm missing the possibility to send new HTTP requests inside Gotham handlers because currently it's not possible to get a reference to the underlying Tokio event loop.
@bradleybeddoes pointed me to
gotham/src/handler/mod.rs
Line 151 in 953c39b
An alternative to having Gotham put the handle reference into the state object would be to use a middleware for that: https://github.com/ChristophWurst/gotham-middleware-tokio. You can find an example usage here: https://github.com/ChristophWurst/gotham-middleware-tokio/blob/master/examples/hyper_client.rs#L22
There seem to be a few problems though. I don't know whether we should use a
Handle
, aRemote
or let the developer choose.Handle
cannot be shared across threads. However, Hyper expects aHandle
rather than aRemote
for its client, making it a bit cumbersome to use. The remote object does have method to get a handle, although it's not guaranteed to always get one.This is somewhat related to hyperium/hyper#1002
@bradleybeddoes @smangelsdorf thoughts on how to integrate this in Gotham?
The text was updated successfully, but these errors were encountered: