Created
March 22, 2018 02:24
-
-
Save jamisonhyatt/dd9d93b978472c960c9fa81b9f39fcf9 to your computer and use it in GitHub Desktop.
Revisions
-
jamisonhyatt created this gist
Mar 22, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ package main import ( "context" "fmt" "log" "github.com/jamisonhyatt/grpc-multi-pkg-protos/pkg/external/location" "github.com/jamisonhyatt/grpc-multi-pkg-protos/pkg/weatherman" desktop "github.com/jamisonhyatt/grpc-multi-pkg-protos/pkg/weatherman/desktop_svc" mobile "github.com/jamisonhyatt/grpc-multi-pkg-protos/pkg/weatherman/mobile_svc" "google.golang.org/grpc" ) func main() { var opts []grpc.DialOption opts = append(opts, grpc.WithInsecure()) conn, err := grpc.Dial("localhost:8000", opts...) if err != nil { log.Fatalf("fail to dial: %v", err) } defer conn.Close() mobileClient := mobile.NewMobileClient(conn) desktopClient := desktop.NewDesktopClient(conn) weathermanClient := weatherman.NewWeathermanClient(conn) health, err := weathermanClient.Healthcheck(context.Background(), &weatherman.HealthCheckRequest{}) if err != nil || !health.Healthy { panic("uhoh") } fmt.Printf("health: %v\n", health) mobileWeather, err := mobileClient.GetWeather(context.Background(), &mobile.GetWeatherRequest{City: &location.City{ Name: "Seattle", State: location.State_WASHINGTON, }}) if err != nil || !mobileWeather.Forecast.Rain { panic("definitely not right") } fmt.Printf("Mobile Client Seattle Weather: %v\n", mobileWeather) desktopWeather, err := desktopClient.GetWeather(context.Background(), &desktop.GetWeatherRequest{City: &location.City{ Name: "Seattle", State: location.State_WASHINGTON, }}) if err != nil || !desktopWeather.Forecast.Rain { panic("definitely not right") } fmt.Printf("Desktop Client Seattle Weather: %v\n", desktopWeather) }