MCPcopy
hub / github.com/dgraph-io/dgraph / SetupConnection

Function SetupConnection

x/x.go:941–967  ·  view source on GitHub ↗

SetupConnection starts a secure gRPC connection to the given host.

(
	host string,
	tlsCfg *tls.Config,
	useGz bool,
	dialOpts ...grpc.DialOption,
)

Source from the content-addressed store, hash-verified

939
940// SetupConnection starts a secure gRPC connection to the given host.
941func 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.
970func Diff(dst map[string]struct{}, src map[string]struct{}) ([]string, []string) {

Callers 7

TestXidmapFunction · 0.92
TestXidmapMemoryFunction · 0.92
BenchmarkXidmapWritesFunction · 0.92
BenchmarkXidmapReadsFunction · 0.92
GetDgraphClientFunction · 0.85

Calls

no outgoing calls

Tested by 6

TestXidmapFunction · 0.74
TestXidmapMemoryFunction · 0.74
BenchmarkXidmapWritesFunction · 0.74
BenchmarkXidmapReadsFunction · 0.74