Added separate client for additional testing

This commit is contained in:
Andrew Scott 2022-07-26 01:07:26 -04:00
parent 0b5d1b1b6b
commit 14837a3549
Signed by: a
GPG key ID: 3EB62D0BBB8DB381
2 changed files with 42 additions and 0 deletions

20
test-client/current.go Normal file
View file

@ -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)
}

22
test-client/main.go Normal file
View file

@ -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)
}