Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,333 changes: 717 additions & 616 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7", features = ["codec"] }
tracing = "0.1"
hyper = { version = "1", features = ["full"] }
http = "1.1.0"
http = "1.2.0"
async-trait = "0.1"
wasmtime = { version = "20.0.2" }
wasmtime-wasi = { version = "20.0.2" }
wasi-common = { version = "20.0.2" }
wasmtime-wasi-nn = { version = "20.0.2" }
wasmtime = { version = "29.0.1", git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}
wasmtime-wasi = { version = "29.0.1", git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}
wasi-common = { version = "29.0.1", git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}
wasmtime-wasi-nn = { version = "29.0.1", features = ["openvino", "candle"], git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}
wasmtime-wasi-http = { version = "29.0.1", git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}
wasmtime-environ = { version = "29.0.1", git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}

clap = { version = "4", features = ["derive"] }
moka = { version = "0.12", features = ["sync"] }
smol_str = { version = "0.2.1", features = ["serde"] }
smol_str = { version = "0.3.2", features = ["serde"] }
anyhow = "1.0"

[workspace.lints.rust]
Expand Down
23 changes: 0 additions & 23 deletions crates/candle-wasi-nn/Cargo.toml

This file was deleted.

201 changes: 0 additions & 201 deletions crates/candle-wasi-nn/src/lib.rs

This file was deleted.

3 changes: 0 additions & 3 deletions crates/dictionary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ description = "dictionary host function"

[dependencies]
reactor = { path = "../reactor" }
anyhow = {workspace = true}
tracing = {workspace = true}
async-trait = {workspace = true}
wasmtime = {workspace = true}

[lints]
workspace = true
6 changes: 2 additions & 4 deletions crates/dictionary/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use async_trait::async_trait;
use reactor::gcore::fastedge::dictionary;
use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
Expand All @@ -8,10 +7,9 @@ pub struct Dictionary {
inner: HashMap<String, String>,
}

#[async_trait]
impl dictionary::Host for Dictionary {
async fn get(&mut self, name: String) -> anyhow::Result<Option<String>> {
Ok(self.inner.get(&name).map(|v| v.to_string()))
async fn get(&mut self, name: String) -> Option<String> {
self.inner.get(&name).map(|v| v.to_string())
}
}

Expand Down
13 changes: 5 additions & 8 deletions crates/http-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,17 @@ description = "Client component for outbound http requests"
[dependencies]
reactor = { path = "../reactor" }
http = {workspace = true}
async-trait = {workspace = true}
anyhow = {workspace = true}
tracing = {workspace = true}
hyper = { workspace = true }
tokio = { workspace = true }
hyper-util = { version = "0.1.3", features = ["client", "client-legacy", "http1", "tokio"] }
http-body-util = "0.1.1"
pin-project = "1.1.3"
log = "0.4.20"
url = "2.5.0"
tower-service = "0.3.2"
hyper-util = { version = "0.1.10", features = ["client", "client-legacy", "http1", "tokio"] }
http-body-util = "0.1.2"
pin-project = "1.1.8"
tower-service = "0.3.3"
smol_str = {workspace = true}

[dev-dependencies]
claims = "0.7"
claims = "0.8"
tracing-test = "0.2"
mock-http-connector = "0.3"
26 changes: 17 additions & 9 deletions crates/http-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::task::{Context, Poll};
use std::time::Duration;

use anyhow::{anyhow, Error, Result};
use async_trait::async_trait;
use http::{header, uri::Scheme, HeaderMap, HeaderName, Uri};
use http_body_util::{BodyExt, Full};
use hyper::body::Bytes;
Expand Down Expand Up @@ -268,21 +267,26 @@ impl<C> Backend<C> {
}
}

#[async_trait]
impl<C> Host for Backend<C>
where
C: Connect + Clone + Send + Sync + 'static,
{
async fn send_request(&mut self, req: Request) -> Result<Result<Response, HttpError>> {
async fn send_request(&mut self, req: Request) -> Result<Response, HttpError> {
// check the limit of sub requests
if self.max_sub_requests == 0 {
return Ok(Err(HttpError::TooManyRequests));
return Err(HttpError::TooManyRequests);
} else {
self.max_sub_requests -= 1;
}

let request = self.make_request(req)?;
let res = self.client.request(request).await?;
let request = self
.make_request(req)
.map_err(|_| HttpError::RequestError)?;
let res = self
.client
.request(request)
.await
.map_err(|_| HttpError::RequestError)?;

let status = res.status().as_u16();
let (parts, body) = res.into_parts();
Expand All @@ -304,16 +308,20 @@ where
None
};

let body_bytes = body.collect().await?.to_bytes();
let body_bytes = body
.collect()
.await
.map_err(|_| HttpError::RequestError)?
.to_bytes();
let body = Some(body_bytes.to_vec());

trace!(?status, ?headers, len = body_bytes.len(), "reply");

Ok(Ok(Response {
Ok(Response {
status,
headers,
body,
}))
})
}
}

Expand Down
Loading