MCPcopy
hub / github.com/sqlc-dev/sqlc / NewClient

Function NewClient

internal/remote/rpc.go:16–35  ·  view source on GitHub ↗
(cloudConfig config.Cloud)

Source from the content-addressed store, hash-verified

14const defaultHostname = "remote.sqlc.dev"
15
16func NewClient(cloudConfig config.Cloud) (GenClient, error) {
17 authID := cloudConfig.Organization + "/" + cloudConfig.Project
18 opts := []grpc.DialOption{
19 grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
20 grpc.WithPerRPCCredentials(basic.NewPerRPCCredentials(authID, cloudConfig.AuthToken)),
21 grpc.WithUnaryInterceptor(rpc.UnaryInterceptor),
22 }
23
24 hostname := cloudConfig.Hostname
25 if hostname == "" {
26 hostname = defaultHostname
27 }
28
29 conn, err := grpc.Dial(hostname+":443", opts...)
30 if err != nil {
31 return nil, err
32 }
33
34 return NewGenClient(conn), nil
35}

Callers 1

remoteGenerateFunction · 0.92

Calls 1

NewGenClientFunction · 0.85

Tested by

no test coverage detected