forked from bytecodealliance/wrpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e705fcf
commit 2c24bcb
Showing
78 changed files
with
5,014 additions
and
88 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "wrpc-cli" | ||
version = "0.1.0" | ||
description = "wRPC CLI" | ||
publish = false | ||
|
||
authors.workspace = true | ||
categories.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
|
||
[features] | ||
default = ["nats"] | ||
nats = ["dep:async-nats", "dep:tokio", "tokio/sync", "dep:url"] | ||
|
||
[dependencies] | ||
anyhow = { workspace = true } | ||
async-nats = { workspace = true, optional = true } | ||
tokio = { workspace = true, optional = true } | ||
tracing-subscriber = { workspace = true, features = [ | ||
"ansi", | ||
"env-filter", | ||
"fmt", | ||
"smallvec", | ||
"tracing-log", | ||
] } | ||
url = { workspace = true, optional = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#[cfg(feature = "nats")] | ||
pub mod nats; | ||
pub mod tracing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use anyhow::Context as _; | ||
use tokio::sync::mpsc; | ||
use url::Url; | ||
|
||
pub const DEFAULT_URL: &str = "nats://127.0.0.1:4222"; | ||
|
||
/// Connect to NATS.io server and ensure that the connection is fully established before | ||
/// returning the resulting [`async_nats::Client`] | ||
pub async fn connect(url: Url) -> anyhow::Result<async_nats::Client> { | ||
let (conn_tx, mut conn_rx) = mpsc::channel(1); | ||
let client = async_nats::connect_with_options( | ||
String::from(url), | ||
async_nats::ConnectOptions::new() | ||
.retry_on_initial_connect() | ||
.event_callback(move |event| { | ||
let conn_tx = conn_tx.clone(); | ||
async move { | ||
if let async_nats::Event::Connected = event { | ||
conn_tx | ||
.send(()) | ||
.await | ||
.expect("failed to send NATS.io server connection notification"); | ||
} | ||
} | ||
}), | ||
) | ||
.await | ||
.context("failed to connect to NATS.io server")?; | ||
conn_rx | ||
.recv() | ||
.await | ||
.context("failed to await NATS.io server connection to be established")?; | ||
Ok(client) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use tracing_subscriber::layer::SubscriberExt as _; | ||
use tracing_subscriber::util::SubscriberInitExt as _; | ||
|
||
pub fn env_filter() -> tracing_subscriber::EnvFilter { | ||
tracing_subscriber::EnvFilter::try_from_default_env() | ||
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")) | ||
} | ||
|
||
pub fn init() { | ||
tracing_subscriber::registry() | ||
.with(tracing_subscriber::fmt::layer().compact().without_time()) | ||
.with(env_filter()) | ||
.init(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
[package] | ||
name = "wrpc-wasmtime-nats-cli" | ||
version = "0.1.0" | ||
description = "wRPC Wasmtime NATS CLI" | ||
publish = false | ||
|
||
authors.workspace = true | ||
categories.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
anyhow = { workspace = true } | ||
async-nats = { workspace = true } | ||
clap = { workspace = true, features = [ | ||
"color", | ||
"derive", | ||
"error-context", | ||
"help", | ||
"std", | ||
"suggestions", | ||
"usage", | ||
] } | ||
futures = { workspace = true } | ||
hyper = { workspace = true, features = ["server"] } | ||
hyper-util = { workspace = true, features = ["server-auto", "tokio"] } | ||
reqwest = { workspace = true } | ||
tokio = { workspace = true, features = ["fs"] } | ||
tracing = { workspace = true, features = ["attributes"] } | ||
tracing-subscriber = { workspace = true, features = [ | ||
"ansi", | ||
"env-filter", | ||
"fmt", | ||
] } | ||
url = { workspace = true } | ||
wasmcloud-component-adapters = { workspace = true } | ||
wasmparser = { workspace = true } | ||
wasmtime = { workspace = true, features = [ | ||
"addr2line", | ||
"async", | ||
"cache", | ||
"coredump", | ||
"cranelift", | ||
"demangle", | ||
"gc", | ||
"parallel-compilation", | ||
"runtime", | ||
"threads", | ||
"wat", | ||
] } | ||
wasmtime-wasi = { workspace = true } | ||
wasmtime-wasi-http = { workspace = true } | ||
wit-bindgen-wrpc = { workspace = true } | ||
wit-component = { workspace = true } | ||
wit-parser = { workspace = true } | ||
wrpc-cli = { workspace = true, features = ["nats"] } | ||
wrpc-transport = { workspace = true } | ||
wrpc-transport-nats = { workspace = true } | ||
wrpc-types = { workspace = true } | ||
wrpc-interface-http = { workspace = true, features = [ | ||
"http", | ||
"http-body", | ||
"hyper", | ||
"wasmtime-wasi-http", | ||
] } | ||
wrpc-runtime-wasmtime = { workspace = true } |
Oops, something went wrong.