diff options
| author | mo khan <mo@mokhan.ca> | 2025-06-18 15:37:54 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-06-18 15:37:54 -0600 |
| commit | c598f54c80329ea454f3942ca61b447a0f690e98 (patch) | |
| tree | 148a184ce938bb2f82ed70ec1300c2f438694422 | |
| parent | c9eff3857f706138bf96a959702c41815815cc3e (diff) | |
feat: create the rpc client
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | src/client.rs | 20 |
2 files changed, 24 insertions, 0 deletions
@@ -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(()) +} |
