-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Client builder's executor setter is confusing for new tokio 0.2 alpha #1944
Comments
Yea, some impls could probably be added to Tokio... However, it seems like the |
I'm currently facing this issue as well. Code is let runtime = tokio::runtime::Builder::new().build().unwrap();
let mut https = HttpsConnector::new().unwrap();
https.https_only(true);
let client = hyper::Client::builder()
.executor(runtime.executor())
.build::<_, hyper::Body>(https); Anyone have a good way to work around this issue currently or am I stuck waiting for an official hyper/tokio fix? |
@sparky8251 Currently you need to create a new executor, something like this (not tested): struct DefaultExecutor(TaskExecutor);
impl Executor for DefaultExecutor {
fn spawn(
&mut self,
future: Pin<Box<dyn Future<Output = ()> + Send>>
) -> Result<(), tokio_executor::SpawnError> {
Ok(self.0.spawn(future))
}
fn status(&self) -> Result<(), tokio_executor::SpawnError> {
self.0.status()
}
}
impl Executor for &DefaultExecutor {
fn spawn(
&mut self,
future: Pin<Box<dyn Future<Output = ()> + Send>>
) -> Result<(), tokio_executor::SpawnError> {
Ok(self.0.spawn(future))
}
fn status(&self) -> Result<(), tokio_executor::SpawnError> {
self.0.status()
}
} |
Instead of custom executors needing to be `tokio::Executor` or `tokio::TypedExecutor`, they are now just `Fn`s. BREAKING CHANGE: Configuring an `executor` for a client or server should now pass a closure or function to spawn the future. Closes #1944
futures::task::Spawn has landed. |
Instead of custom executors needing to be `tokio::Executor` or `tokio::TypedExecutor`, they are now just `Fn`s. BREAKING CHANGE: Configuring an `executor` for a client or server should now pass a closure or function to spawn the future. Closes #1944
Instead of custom executors needing to be `tokio::Executor` or `tokio::TypedExecutor`, they are now just `Fn`s. BREAKING CHANGE: Configuring an `executor` for a client or server should now pass a closure or function to spawn the future. Closes #1944
The `hyper::rt::Executor` trait allows defining custom executors to be used with hyper's `Client` and `Server`. Closes #1944 BREAKING CHANGE: Any type passed to the `executor` builder methods must now implement `hyper::rt::Executor`. `hyper::rt::spawn` usage should be replaced with `tokio::task::spawn`. `hyper::rt::run` usage should be replaced with `#[tokio::main]` or managing a `tokio::runtime::Runtime` manually.
The `hyper::rt::Executor` trait allows defining custom executors to be used with hyper's `Client` and `Server`. Closes #1944 BREAKING CHANGE: Any type passed to the `executor` builder methods must now implement `hyper::rt::Executor`. `hyper::rt::spawn` usage should be replaced with `tokio::task::spawn`. `hyper::rt::run` usage should be replaced with `#[tokio::main]` or managing a `tokio::runtime::Runtime` manually.
Currently in hyper, the
Builder::executor<E>()
setter requires afor<'a> &'a E: tokio_executor::Executor
bound. Which, in latest tokio (=0.2.0-alpha.4
), onlySender
meets this bound.However,
Sender
is now not exported anymore by tokio. There seems to be no easy way to set custom executor.The text was updated successfully, but these errors were encountered: