From 14837a3549e6b6b40d165cd6ff467e27fae5fd4a Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Tue, 26 Jul 2022 01:07:26 -0400 Subject: [PATCH] Added separate client for additional testing --- test-client/current.go | 20 ++++++++++++++++++++ test-client/main.go | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test-client/current.go create mode 100644 test-client/main.go diff --git a/test-client/current.go b/test-client/current.go new file mode 100644 index 0000000..a6e13f5 --- /dev/null +++ b/test-client/current.go @@ -0,0 +1,20 @@ +package main + +import ( + "context" + "log" + + pb "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto" +) + +func doCurrent(c pb.WeatherServiceClient) { + + res, err := c.Current(context.Background(), &pb.RequestCurrent{ + City: "Corvallis", + }) + if err != nil { + log.Fatalln(err) + } + + log.Println(res.Payload) +} diff --git a/test-client/main.go b/test-client/main.go new file mode 100644 index 0000000..f456cd3 --- /dev/null +++ b/test-client/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "log" + + pb "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +func main() { + + conn, err := grpc.Dial("localhost:5000", grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatalln(err) + } + defer conn.Close() + + c := pb.NewWeatherServiceClient(conn) + + doCurrent(c) +}