diff --git a/Cargo.lock b/Cargo.lock index 1bded5786d..5b97c43023 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -119,6 +119,15 @@ version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +[[package]] +name = "api_client" +version = "0.16.0" +dependencies = [ + "jj-api", + "tokio", + "tonic", +] + [[package]] name = "arc-swap" version = "1.7.1" diff --git a/Cargo.toml b/Cargo.toml index 2c42de10d7..9cfe4b5c91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ cargo-features = [] [workspace] resolver = "2" -members = [ "api", "cli", "lib", "lib/gen-protos", "lib/proc-macros", "lib/testutils"] +members = [ "api", "api_client","cli", "lib", "lib/gen-protos", "lib/proc-macros", "lib/testutils"] [workspace.package] version = "0.16.0" @@ -102,6 +102,7 @@ tokio = { version = "1.37.0", features = ["rt", "macros"] } toml_edit = { version = "0.19.15", features = ["serde"] } tonic = "0.11.0" tonic-build = "0.11.0" +tonic-reflection = "0.11.0" tonic-web = "0.11.0" tracing = "0.1.40" tracing-chrome = "0.7.2" diff --git a/api_client/Cargo.toml b/api_client/Cargo.toml new file mode 100644 index 0000000000..64a13edb17 --- /dev/null +++ b/api_client/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "api_client" +version.workspace = true +license.workspace = true +rust-version.workspace = true +edition.workspace = true +readme.workspace = true +homepage.workspace = true +repository.workspace = true +documentation.workspace = true +categories.workspace = true +keywords.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +tonic.workspace = true +jj-api.workspace = true +tokio = { workspace = true, features = ["full"] } \ No newline at end of file diff --git a/api_client/src/main.rs b/api_client/src/main.rs new file mode 100644 index 0000000000..e521b3441c --- /dev/null +++ b/api_client/src/main.rs @@ -0,0 +1,15 @@ +use jj_api::client::JjServiceClient; +use jj_api::rpc::ListWorkspacesRequest; + +#[tokio::main] +async fn main() -> Result<(), Box> { + let mut client = JjServiceClient::connect("http://[::1]:8888").await?; + + let request = tonic::Request::new(ListWorkspacesRequest::default()); + + let response = client.list_workspaces(request).await?; + + println!("RESPONSE={:?}", response); + + Ok(()) +}