-
I have the following:
[package]
name = "kube-tokio"
version = "0.1.0"
edition = "2018"
[dependencies]
http = "0"
k8s-openapi = { version = "0.12", default-features = false, features = ["v1_17"] }
kube = "=0.58.1"
use http::Uri;
use kube::{Client, Config};
use std::convert::TryFrom;
use std::str::FromStr;
fn main() {
let config = Config::new(Uri::from_str("https://not.a.real.cluster").unwrap());
let _client = Client::try_from(config).unwrap();
} This panics with:
Rust async ecosystems are still confusing and vexing for me. I'm surprised here that these non-async functions require a "Reactor". Is it safe to say that P.S. This works: #[tokio::main]
async fn main() {
let config = Config::new(Uri::from_str("https://not.a.real.cluster").unwrap());
let _client = Client::try_from(config).unwrap();
} I think I just need to go back through my stuff and use tokio instead of async-std, and assume I need the runtime even for these non-async functions. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ah, yeah. Just because a function is not marked as It's probably not a good idea to try this crate without an executor. I think without all the default-features, and possibly only using the kube builds on almost all the core crates within tokio, and while there are some compatibility layers within async-std that they have under their org, I would not recommend going down that route unless you have to. They are really quite far behind tokio right now. |
Beta Was this translation helpful? Give feedback.
Ah, yeah. Just because a function is not marked as
async
does not mean they don't necessarily do async stuf under the hood.In particular,
Client::try_from(config)
, sets up all the layers that's basically using things from hyper, tower, tower-http, and binds async handlers internally (which is probably where it's failing here).It's probably not a good idea to try this crate without an executor. I think without all the default-features, and possibly only using the
config
feature, you could maybe do something, but almost certainly nothing to do with the client.kube builds on almost all the core crates within tokio, and while there are some compatibility layers within async-std that they h…