Skip to content

chore(wit-bindgen-rust): switch to new transport abstraction #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 1, 2024
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
92 changes: 12 additions & 80 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 2 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wrpc"
version = "0.3.0"
version = "0.2.0"
description = "WebAssembly component-native RPC framework based on WIT"

authors.workspace = true
Expand Down Expand Up @@ -41,7 +41,6 @@ nats = [
"dep:async-nats",
"dep:wrpc-transport-nats",
"wrpc-cli/nats",
"dep:wrpc-transport-nats-legacy", # TODO: Remove
]
quic = ["dep:wrpc-transport-quic"]
wasmtime = ["dep:wrpc-runtime-wasmtime"]
Expand Down Expand Up @@ -81,12 +80,8 @@ wrpc-transport-nats = { workspace = true, optional = true }
wrpc-transport-quic = { workspace = true, optional = true }
wrpc-wasmtime-nats-cli = { workspace = true, optional = true }

# TODO: Remove
wrpc-transport-nats-legacy = { workspace = true, optional = true }

[dev-dependencies]
anyhow = { workspace = true }
async-nats = { workspace = true }
bytes = { workspace = true }
futures = { workspace = true, features = ["async-await"] }
rcgen = { workspace = true, features = ["crypto", "ring", "zeroize"] }
Expand All @@ -102,9 +97,6 @@ quinn = { workspace = true, features = [
] }
wrpc-cli = { workspace = true }

# TODO: Remove
wrpc-transport-legacy = { workspace = true }

[workspace.dependencies]
anyhow = { version = "1", default-features = false }
async-nats = { version = "0.35", git = "https://github.com/rvolosatovs/nats.rs", branch = "feat/command-sender", default-features = false }
Expand Down Expand Up @@ -134,7 +126,7 @@ tower = { version = "0.4", default-features = false }
tracing = { version = "0.1", default-features = false }
tracing-subscriber = { version = "0.3", default-features = false }
url = { version = "2", default-features = false }
wasm-tokio = { version = "0.5.14", default-features = false }
wasm-tokio = { version = "0.5.16", default-features = false }
wasmcloud-component-adapters = { version = "0.9", default-features = false }
wasmparser = { version = "0.208", default-features = false }
wasmtime = { version = "21", default-features = false }
Expand All @@ -155,7 +147,3 @@ wrpc-transport = { version = "0.26", path = "./crates/transport", default-featur
wrpc-transport-nats = { version = "0.22", path = "./crates/transport-nats", default-features = false }
wrpc-transport-quic = { version = "0.1", path = "./crates/transport-quic", default-features = false }
wrpc-wasmtime-nats-cli = { version = "0.2", path = "./crates/wasmtime-nats-cli", default-features = false }

# TODO: Remove
wrpc-transport-legacy = { version = "0.24.3", path = "./crates/transport-legacy", default-features = false }
wrpc-transport-nats-legacy = { version = "0.21", path = "./crates/transport-nats-legacy", default-features = false }
19 changes: 6 additions & 13 deletions crates/runtime-wasmtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use core::pin::{pin, Pin};
use std::collections::HashSet;
use std::sync::Arc;

use anyhow::{anyhow, bail, Context as _};
use anyhow::{bail, Context as _};
use bytes::{BufMut as _, Bytes, BytesMut};
use futures::future::try_join_all;
use futures::stream::FuturesUnordered;
Expand All @@ -29,7 +29,7 @@ use wasmtime::component::{LinkerInstance, ResourceType, Type, Val};
use wasmtime::{AsContextMut, Engine, StoreContextMut};
use wasmtime_wasi::pipe::AsyncReadStream;
use wasmtime_wasi::{InputStream, StreamError, WasiView};
use wrpc_transport::{Index as _, Invocation, Invoke, ListDecoderU8, Session};
use wrpc_transport::{Index as _, Invoke, ListDecoderU8};

pub struct RemoteResource(pub Bytes);

Expand Down Expand Up @@ -468,7 +468,7 @@ where
w.write_all(&chunk).await?;
}
Err(StreamError::Closed) => {
w.write_all(&[0x00]).await?
w.write_all(&[0x00]).await?;
}
Err(err) => return Err(err.into()),
}
Expand All @@ -494,7 +494,7 @@ where
w.write_all(&chunk).await?;
}
Err(StreamError::Closed) => {
w.write_all(&[0x00]).await?
w.write_all(&[0x00]).await?;
}
Err(err) => return Err(err.into()),
}
Expand Down Expand Up @@ -946,11 +946,7 @@ where
.context("failed to encode parameter")?;
deferred.push(enc.deferred);
}
let Invocation {
outgoing,
incoming,
session,
} = store
let (outgoing, incoming) = store
.data()
.client()
.invoke(cx, &instance, &name, buf.freeze(), &[[]])
Expand Down Expand Up @@ -985,10 +981,7 @@ where
Ok(())
},
)?;
match session.finish(Ok(())).await? {
Ok(()) => Ok(()),
Err(err) => bail!(anyhow!("{err}").context("session failed")),
}
Ok(())
})
})
}
31 changes: 0 additions & 31 deletions crates/transport-legacy/Cargo.toml

This file was deleted.

Loading