Created
December 27, 2019 20:26
Revisions
-
Stoakes created this gist
Dec 27, 2019 .There are no files selected for viewing
This file contains 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,10 @@ { "xds_servers": [ { "server_uri": "istio-pilot:15010", "channel_creds": [{}] }], "node": { "id": "sidecar~192.168.0.1~xds.default~default.svc.cluster.local" } } This file contains 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,48 @@ package main import ( "io/ioutil" "os" "github.com/Stoakes/go-pkg/log" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/grpclog" _ "google.golang.org/grpc/xds/experimental" ) var ( xdsScheme = "xds-experimental-new" helloService = "localhost:8080" ) func main() { logg := grpclog.NewLoggerV2(os.Stdout, ioutil.Discard, ioutil.Discard) grpclog.SetLoggerV2(logg) ctx, cancel := context.WithCancel(context.Background()) defer cancel() log.Setup(ctx, log.Options{ Debug: true, LogLevel: "debug", AppName: "xds-demo", AppID: "appId", Version: "0.0.1", }) log.For(ctx).Info("Connecting to hello service at " + helloService) _, err := dial(helloService) if err != nil { log.For(ctx).Fatalf("Connection to hello-service error :%v", err) } } // Dial dial an headless service with loadBalancing Options func dial(targetStr string, dialOpts ...grpc.DialOption) (*grpc.ClientConn, error) { log.Bg().Debug("Dialing " + xdsScheme + ":///" + targetStr) return grpc.Dial(xdsScheme+":///"+targetStr, []grpc.DialOption{ grpc.WithBlock(), grpc.WithInsecure()}..., ) } This file contains 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,3 @@ #!/bin/bash GRPC_GO_LOG_SEVERITY_LEVEL=16 GRPC_XDS_BOOTSTRAP=$(pwd)/config.json ./xds-demo