feat(sdk,core): Use async runtime instead of blocking.

Default to using async runtime instead of blocking. I.e.

```rust
fn main() -> eyre::Result<()> {
  // ...

  client.container().from("rust").publish("somewhere")?;

  // ...
}

// to

async fn main() -> eyre::Result<()> {
  // ...

  client.container().from("rust").publish("somewhere").await?;

  // ...
}
```
This commit is contained in:
2023-02-19 21:37:54 +01:00
committed by Kasper Juul Hermansen
parent c35c104b49
commit 9be6f435d9
12 changed files with 778 additions and 395 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -93,18 +93,13 @@ impl Selection {
Ok(fields.join("{") + &"}".repeat(fields.len() - 1))
}
pub fn execute<D>(&self, gql_client: &gql_client::Client) -> eyre::Result<D>
pub async fn execute<D>(&self, gql_client: &gql_client::Client) -> eyre::Result<D>
where
D: for<'de> Deserialize<'de>,
{
let query = self.build()?;
let basic = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
let resp: Option<serde_json::Value> = match basic.block_on(gql_client.query(&query)) {
let resp: Option<serde_json::Value> = match gql_client.query(&query).await {
Ok(r) => r,
Err(e) => eyre::bail!(e),
};