fix(core): Fix async panic on blocking #19

Replaced internal threads with tokio spawn functions
This commit is contained in:
2023-02-20 10:10:42 +01:00
committed by Kasper Juul Hermansen
parent 45d6462037
commit 75bc17e57d
21 changed files with 66 additions and 61 deletions

View File

@@ -2,7 +2,7 @@ use dagger_sdk::HostDirectoryOpts;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect()?;
let client = dagger_sdk::connect().await?;
let host_source_dir = client.host().directory_opts(
"examples/build-the-application/app",

View File

@@ -2,7 +2,7 @@ use rand::Rng;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect()?;
let client = dagger_sdk::connect().await?;
let host_source_dir = client.host().directory_opts(
"./examples/caching/app",

View File

@@ -4,7 +4,7 @@ use rand::Rng;
async fn main() -> eyre::Result<()> {
let mut rng = rand::thread_rng();
let client = dagger_sdk::connect()?;
let client = dagger_sdk::connect().await?;
let context_dir = client
.host()

View File

@@ -1,6 +1,6 @@
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect()?;
let client = dagger_sdk::connect().await?;
let version = client
.container()

View File

@@ -3,7 +3,7 @@ use rand::Rng;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect()?;
let client = dagger_sdk::connect().await?;
let host_source_dir = client.host().directory_opts(
"examples/publish-the-application/app",

View File

@@ -3,7 +3,7 @@ use rand::Rng;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect()?;
let client = dagger_sdk::connect().await?;
let output = "examples/publish-the-application/app/build";
let host_source_dir = client.host().directory_opts(

View File

@@ -2,7 +2,7 @@ use dagger_sdk::HostDirectoryOpts;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect()?;
let client = dagger_sdk::connect().await?;
let host_source_dir = client.host().directory_opts(
"examples/test-the-application/app",

View File

@@ -13,9 +13,9 @@ use crate::querybuilder::query;
pub type DaggerConn = Arc<Query>;
pub fn connect() -> eyre::Result<DaggerConn> {
pub async fn connect() -> eyre::Result<DaggerConn> {
let cfg = Config::default();
let (conn, proc) = DaggerEngine::new().start(&cfg)?;
let (conn, proc) = DaggerEngine::new().start(&cfg).await?;
Ok(Arc::new(Query {
conn,
@@ -44,8 +44,8 @@ pub fn graphql_client(conn: &ConnectParams) -> gql_client::Client {
mod test {
use super::connect;
#[test]
fn test_connect() {
let _ = connect().unwrap();
#[tokio::test]
async fn test_connect() {
let _ = connect().await.unwrap();
}
}

View File

@@ -22,8 +22,8 @@ pub struct SecretId(String);
pub struct SocketId(String);
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct BuildArg {
pub name: String,
pub value: String,
pub name: String,
}
pub struct CacheVolume {
pub proc: Arc<Child>,

View File

@@ -2,7 +2,7 @@ use dagger_sdk::{connect, ContainerExecOptsBuilder};
#[tokio::test]
async fn test_example_container() {
let client = connect().unwrap();
let client = connect().await.unwrap();
let alpine = client.container().from("alpine:3.16.2");