mirror of
https://codeberg.org/andyscott/OpenWeather-gRPC-API.git
synced 2024-11-04 05:10:48 -05:00
Added separate client for additional testing
This commit is contained in:
parent
0b5d1b1b6b
commit
14837a3549
2 changed files with 42 additions and 0 deletions
20
test-client/current.go
Normal file
20
test-client/current.go
Normal 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
22
test-client/main.go
Normal 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)
|
||||
}
|
Loading…
Reference in a new issue