summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-18 15:37:54 -0600
committermo khan <mo@mokhan.ca>2025-06-18 15:37:54 -0600
commitc598f54c80329ea454f3942ca61b447a0f690e98 (patch)
tree148a184ce938bb2f82ed70ec1300c2f438694422
parentc9eff3857f706138bf96a959702c41815815cc3e (diff)
feat: create the rpc client
-rw-r--r--Makefile4
-rw-r--r--src/client.rs20
2 files changed, 24 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 4663b07..a6c4a32 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,10 @@ help:
clean:
@cargo clean
+.PHONY: client
+client:
+ @cargo run --bin helloworld-client
+
.PHONY: server
server:
@cargo run --bin helloworld-server
diff --git a/src/client.rs b/src/client.rs
new file mode 100644
index 0000000..aaf42de
--- /dev/null
+++ b/src/client.rs
@@ -0,0 +1,20 @@
+use hello_world::HelloRequest;
+use hello_world::greeter_client::GreeterClient;
+
+pub mod hello_world {
+ tonic::include_proto!("helloworld");
+}
+
+#[tokio::main]
+async fn main() -> Result<(), Box<dyn std::error::Error>> {
+ let mut client = GreeterClient::connect("http://[::1]:50051").await?;
+
+ let request = tonic::Request::new(HelloRequest {
+ name: "Tonic".into(),
+ });
+
+ let response = client.say_hello(request).await?;
+ println!("RESPONSE={:?}", response);
+
+ Ok(())
+}