From 39fffe108a676504a61aae5c061ae63be388e276 Mon Sep 17 00:00:00 2001 From: Dominic Burkart <1351120+DominicBurkart@users.noreply.github.com> Date: Wed, 21 Oct 2020 10:58:25 +0200 Subject: [PATCH] temp bugfix: for some reason, async traits don't seem to handle futures in impls correctly. the error seems to be because the runtime environment is not accessible/out of scope --- turbolift_internals/src/kubernetes.rs | 5 ++++- turbolift_internals/src/local_queue.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/turbolift_internals/src/kubernetes.rs b/turbolift_internals/src/kubernetes.rs index fb768a3d..28afe9d9 100644 --- a/turbolift_internals/src/kubernetes.rs +++ b/turbolift_internals/src/kubernetes.rs @@ -218,7 +218,10 @@ impl DistributionPlatform for K8s { let service_base_url = self.fn_names_to_services.get(function_name).unwrap(); let args = "./".to_string() + function_name + "/" + ¶ms; let query_url = service_base_url.join(&args)?; - let response = self.get(query_url).await?; + + let mut rt = tokio::runtime::Runtime::new().unwrap(); + let response = rt.block_on(self.get(query_url))?; + // ^ todo find out why this code errors if we don't spawn another runtime here Ok(response) } diff --git a/turbolift_internals/src/local_queue.rs b/turbolift_internals/src/local_queue.rs index 9f308b28..c50b71f1 100644 --- a/turbolift_internals/src/local_queue.rs +++ b/turbolift_internals/src/local_queue.rs @@ -96,7 +96,10 @@ impl DistributionPlatform for LocalQueue { // request from server let prefixed_params = "./".to_string() + function_name + "/" + ¶ms; let query_url = address_and_port.join(&prefixed_params)?; - let response = Self::get(query_url).await; + + let mut rt = tokio::runtime::Runtime::new().unwrap(); + let response = rt.block_on(Self::get(query_url)); + // ^ todo find out why this code errors if we don't spawn another runtime here Ok(response) }