SetupConnection starts a secure gRPC connection to the given host.
( host string, tlsCfg *tls.Config, useGz bool, dialOpts ...grpc.DialOption, )
| 939 | |
| 940 | // SetupConnection starts a secure gRPC connection to the given host. |
| 941 | func SetupConnection( |
| 942 | host string, |
| 943 | tlsCfg *tls.Config, |
| 944 | useGz bool, |
| 945 | dialOpts ...grpc.DialOption, |
| 946 | ) (*grpc.ClientConn, error) { |
| 947 | callOpts := append([]grpc.CallOption{}, |
| 948 | grpc.MaxCallRecvMsgSize(GrpcMaxSize), |
| 949 | grpc.MaxCallSendMsgSize(GrpcMaxSize)) |
| 950 | |
| 951 | if useGz { |
| 952 | fmt.Fprintf(os.Stderr, "Using compression with %s\n", host) |
| 953 | callOpts = append(callOpts, grpc.UseCompressor(gzip.Name)) |
| 954 | } |
| 955 | |
| 956 | dialOpts = append(dialOpts, |
| 957 | grpc.WithStatsHandler(&ocgrpc.ClientHandler{}), |
| 958 | grpc.WithDefaultCallOptions(callOpts...)) |
| 959 | |
| 960 | if tlsCfg != nil { |
| 961 | dialOpts = append(dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(tlsCfg))) |
| 962 | } else { |
| 963 | dialOpts = append(dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials())) |
| 964 | } |
| 965 | |
| 966 | return grpc.NewClient(host, dialOpts...) |
| 967 | } |
| 968 | |
| 969 | // Diff computes the difference between the keys of the two given maps. |
| 970 | func Diff(dst map[string]struct{}, src map[string]struct{}) ([]string, []string) { |
no outgoing calls