(address string)
| 380 | } |
| 381 | |
| 382 | func (pc *proxyClients) getClient(address string) (*grpc.ClientConn, error) { |
| 383 | pc.m.Lock() |
| 384 | defer pc.m.Unlock() |
| 385 | if pc.clients == nil { |
| 386 | pc.clients = map[string]*grpc.ClientConn{} |
| 387 | } else if c, ok := pc.clients[address]; ok { |
| 388 | return c, nil |
| 389 | } |
| 390 | |
| 391 | backoffConfig := backoff.DefaultConfig |
| 392 | backoffConfig.MaxDelay = 3 * time.Second |
| 393 | connParams := grpc.ConnectParams{ |
| 394 | Backoff: backoffConfig, |
| 395 | } |
| 396 | gopts := []grpc.DialOption{ |
| 397 | grpc.WithStatsHandler(otelgrpc.NewClientHandler()), |
| 398 | grpc.WithTransportCredentials(insecure.NewCredentials()), |
| 399 | grpc.WithConnectParams(connParams), |
| 400 | grpc.WithContextDialer(dialer.ContextDialer), |
| 401 | |
| 402 | // TODO(stevvooe): We may need to allow configuration of this on the client. |
| 403 | grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(defaults.DefaultMaxRecvMsgSize)), |
| 404 | grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(defaults.DefaultMaxSendMsgSize)), |
| 405 | } |
| 406 | |
| 407 | conn, err := grpc.NewClient(dialer.DialAddress(address), gopts...) |
| 408 | if err != nil { |
| 409 | return nil, fmt.Errorf("failed to dial %q: %w", address, err) |
| 410 | } |
| 411 | |
| 412 | pc.clients[address] = conn |
| 413 | |
| 414 | return conn, nil |
| 415 | } |
| 416 | |
| 417 | func readString(properties map[string]any, key ...string) string { |
| 418 | for i, k := range key { |
no test coverage detected