MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / Dial

Function Dial

cmd/ttn-lw-cli/internal/api/grpc.go:160–175  ·  view source on GitHub ↗

Dial dials a gRPC connection to the target.

(ctx context.Context, target string)

Source from the content-addressed store, hash-verified

158
159// Dial dials a gRPC connection to the target.
160func Dial(ctx context.Context, target string) (*grpc.ClientConn, error) {
161 connMu.Lock()
162 defer connMu.Unlock()
163 logger := log.FromContext(ctx).WithField("target", target)
164 if conn, ok := conns[target]; ok {
165 logger.Debug("Using existing gRPC connection")
166 return conn, nil
167 }
168 logger.Debug("Connecting to gRPC server...")
169 conn, err := newClient(ctx, target)
170 if err != nil {
171 return nil, err
172 }
173 conns[target] = conn
174 return conn, nil
175}
176
177func newClient(ctx context.Context, target string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
178 opts = append(append(rpcclient.DefaultDialOptions(ctx), GetDialOptions()...), opts...)

Callers 15

gateways_claim.goFile · 0.92
clients_access.goFile · 0.92
end_devices.goFile · 0.92
clients.goFile · 0.92
gateways_access.goFile · 0.92
users.goFile · 0.92
relays.goFile · 0.92

Calls 4

FromContextFunction · 0.92
newClientFunction · 0.85
WithFieldMethod · 0.65
DebugMethod · 0.65

Tested by

no test coverage detected