Skip to content

Commit

Permalink
fix(host): remove export joinset
Browse files Browse the repository at this point in the history
Signed-off-by: Brooks Townsend <brooksmtownsend@gmail.com>
  • Loading branch information
brooksmtownsend committed Nov 25, 2024
1 parent 2f78ec5 commit 596914d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 30 deletions.
50 changes: 21 additions & 29 deletions crates/host/src/wasmbus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use serde::{Deserialize, Serialize};
use serde_json::json;
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio::sync::{broadcast, mpsc, watch, RwLock, Semaphore};
use tokio::task::{JoinHandle, JoinSet};
use tokio::task::JoinHandle;
use tokio::time::{interval_at, Instant};
use tokio::{process, select, spawn};
use tokio_stream::wrappers::IntervalStream;
Expand Down Expand Up @@ -1259,39 +1259,31 @@ impl Host {
async move {
join!(
async move {
let mut tasks = JoinSet::new();
let mut exports = stream::select_all(exports);
loop {
let permits = Arc::clone(&permits);
select! {
Some(fut) = exports.next() => {
match fut {
Ok(fut) => {
debug!("accepted invocation, acquiring permit");
let permit = permits.acquire_owned().await;
tasks.spawn(async move {
let _permit = permit;
debug!("handling invocation");
match fut.await {
Ok(()) => {
debug!("successfully handled invocation");
Ok(())
},
Err(err) => {
warn!(?err, "failed to handle invocation");
Err(err)
},
if let Some(fut) = exports.next().await {
match fut {
Ok(fut) => {
debug!("accepted invocation, acquiring permit");
let permit = permits.acquire_owned().await;
spawn(async move {
let _permit = permit;
debug!("handling invocation");
match fut.await {
Ok(()) => {
debug!("successfully handled invocation");
Ok(())
}
});
}
Err(err) => {
warn!(?err, "failed to accept invocation")
}
Err(err) => {
warn!(?err, "failed to handle invocation");
Err(err)
}
}
});
}
}
Some(res) = tasks.join_next() => {
if let Err(err) = res {
error!(?err, "export serving task failed");
Err(err) => {
warn!(?err, "failed to accept invocation")
}
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/rust/components/http-hello-world/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ impl http::Server for Component {
fn handle(
_request: http::IncomingRequest,
) -> http::Result<http::Response<impl http::OutgoingBody>> {
std::thread::sleep(std::time::Duration::from_secs(1));
Ok(http::Response::new("Hello from Rust!\n"))
}
}
2 changes: 1 addition & 1 deletion examples/rust/components/http-hello-world/wasmcloud.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = 1

[[packages]]
name = "wasi:http"
registry = "another.com"
registry = "wasi.dev"

[[packages.versions]]
requirement = "=0.2.2"
Expand Down

0 comments on commit 596914d

Please sign in to comment.