diff --git a/Cargo.lock b/Cargo.lock index f66f0d0ce..31da864da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1322,7 +1322,7 @@ dependencies = [ "log", "openssl-probe", "openssl-sys", - "url 2.2.2", + "url 2.3.0", ] [[package]] @@ -2700,7 +2700,7 @@ dependencies = [ "sha1", "tokio", "tokio-util", - "url 2.2.2", + "url 2.3.0", ] [[package]] @@ -2817,7 +2817,7 @@ dependencies = [ "tokio-rustls", "tokio-util", "tower-service", - "url 2.2.2", + "url 2.3.0", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -4082,13 +4082,12 @@ dependencies = [ [[package]] name = "url" -version = "2.2.2" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +checksum = "22fe195a4f217c25b25cb5058ced57059824a678474874038dc88d211bf508d3" dependencies = [ "form_urlencoded", "idna 0.2.3", - "matches", "percent-encoding 2.1.0", ] @@ -4155,6 +4154,7 @@ dependencies = [ "clap 3.2.18", "cli-common", "git2", + "http", "jaq-core", "logger", "markup-converter", @@ -4165,6 +4165,7 @@ dependencies = [ "tokio", "tracing", "trycmd", + "url 2.3.0", "wasmflow-collection-cli", "wasmflow-grpctar", "wasmflow-oci", @@ -4604,7 +4605,7 @@ version = "0.10.0" dependencies = [ "serde", "thiserror", - "url 2.2.2", + "url 2.3.0", "wasmflow-macros", ] diff --git a/crates/bins/wafl/Cargo.toml b/crates/bins/wafl/Cargo.toml index 2a88e8269..b167ea76d 100644 --- a/crates/bins/wafl/Cargo.toml +++ b/crates/bins/wafl/Cargo.toml @@ -27,6 +27,7 @@ async-recursion = "1.0" nkeys = "0.2" tracing = "0.1" clap = { version = "3.0", features = ["derive", "env"] } +http = "0.2" serde_json = "1.0" thiserror = "1.0" tokio = { version = "1", features = ["macros", "rt-multi-thread"] } @@ -39,6 +40,7 @@ wasmflow-oci = { path = "../../wasmflow/wasmflow-oci" } anyhow = "1.0" markup-converter = "0.2" jaq-core = "0.7" +url = "2.3.0" [dev-dependencies] trycmd = "0.13" diff --git a/crates/bins/wafl/src/commands/rpc.rs b/crates/bins/wafl/src/commands/rpc.rs index 558131998..f8c9a1ea7 100644 --- a/crates/bins/wafl/src/commands/rpc.rs +++ b/crates/bins/wafl/src/commands/rpc.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use clap::{Args, Subcommand}; +use http::Uri; pub(crate) mod invoke; pub(crate) mod list; @@ -23,13 +24,9 @@ pub(crate) enum SubCommands { #[derive(Debug, Clone, Args)] pub(crate) struct ConnectOptions { - /// RPC port. - #[clap(short, long, env = wasmflow_collection_cli::options::env::WAFL_RPC_PORT,action)] - pub(crate) port: u16, - - /// RPC address. - #[clap(short, long, default_value = "127.0.0.1", env = wasmflow_collection_cli::options::env::WAFL_RPC_ADDRESS,action)] - pub(crate) address: String, + /// RPC Url + #[clap(short = 'u', long = "url")] + pub(crate) uri: Uri, /// Path to pem file for TLS connections. #[clap(long, action)] diff --git a/crates/bins/wafl/src/commands/rpc/invoke.rs b/crates/bins/wafl/src/commands/rpc/invoke.rs index 32ca106c3..3a0212e9e 100644 --- a/crates/bins/wafl/src/commands/rpc/invoke.rs +++ b/crates/bins/wafl/src/commands/rpc/invoke.rs @@ -53,7 +53,7 @@ pub(crate) async fn handle(opts: Options) -> Result<()> { let _guard = crate::utils::init_logger(&opts.logging)?; let mut client = wasmflow_rpc::make_rpc_client( - format!("http://{}:{}", opts.connection.address, opts.connection.port), + opts.connection.uri, opts.connection.pem, opts.connection.key, opts.connection.ca, diff --git a/crates/bins/wafl/src/commands/rpc/list.rs b/crates/bins/wafl/src/commands/rpc/list.rs index 8349430ad..cac08fdf1 100644 --- a/crates/bins/wafl/src/commands/rpc/list.rs +++ b/crates/bins/wafl/src/commands/rpc/list.rs @@ -14,7 +14,7 @@ pub(crate) struct Options { pub(crate) async fn handle(opts: Options) -> Result<()> { let _guard = crate::utils::init_logger(&opts.logging)?; let mut client = wasmflow_rpc::make_rpc_client( - format!("http://{}:{}", opts.connection.address, opts.connection.port), + opts.connection.uri, opts.connection.pem, opts.connection.key, opts.connection.ca, diff --git a/crates/bins/wafl/src/commands/rpc/stats.rs b/crates/bins/wafl/src/commands/rpc/stats.rs index abd9adc59..ba2cc0572 100644 --- a/crates/bins/wafl/src/commands/rpc/stats.rs +++ b/crates/bins/wafl/src/commands/rpc/stats.rs @@ -16,7 +16,7 @@ pub(crate) struct Options { pub(crate) async fn handle(opts: Options) -> Result<()> { let _guard = crate::utils::init_logger(&opts.logging)?; let mut client = wasmflow_rpc::make_rpc_client( - format!("http://{}:{}", opts.connection.address, opts.connection.port), + opts.connection.uri, opts.connection.pem, opts.connection.key, opts.connection.ca, diff --git a/crates/wasmflow/wasmflow-rpc/src/client.rs b/crates/wasmflow/wasmflow-rpc/src/client.rs index aba3df605..b50144776 100644 --- a/crates/wasmflow/wasmflow-rpc/src/client.rs +++ b/crates/wasmflow/wasmflow-rpc/src/client.rs @@ -14,17 +14,13 @@ use crate::rpc::invocation_service_client::InvocationServiceClient; use crate::rpc::{ListRequest, StatsRequest, StatsResponse}; /// Create an RPC client form common configuration -pub async fn make_rpc_client + Send>( - address: T, +pub async fn make_rpc_client( + uri: Uri, pem: Option, key: Option, ca: Option, domain: Option, ) -> Result { - let uri: Uri = address - .try_into() - .map_err(|_| RpcClientError::Other("Could not parse URI".to_owned()))?; - let mut builder = Channel::builder(uri); if let (Some(pem), Some(key)) = (pem, key) {