Skip to content

Commit fbd0bf9

Browse files
committed
Make grpc client creation more flexible
1 parent e5e8943 commit fbd0bf9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

grpc/client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Client struct {
1919
metrics *grpcprom.ClientMetrics
2020
}
2121

22-
func NewCLient(addr string, opts ...grpc.DialOption) (*Client, error) {
22+
func NewCLient(ctx context.Context, target string, opts ...grpc.DialOption) (*Client, error) {
2323
metrics := grpcprom.NewClientMetrics( /* opts ...grpcprom.ClientMetricsOption */ )
2424

2525
opts = append(opts,
@@ -31,7 +31,7 @@ func NewCLient(addr string, opts ...grpc.DialOption) (*Client, error) {
3131
),
3232
)
3333

34-
conn, err := grpc.Dial(addr, opts...)
34+
conn, err := grpc.DialContext(ctx, target, opts...)
3535
if err != nil {
3636
return nil, err
3737
}

internal/exporter/exporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type EndpointConfig struct {
2424
func New(endpoints []EndpointConfig) (*Exporter, error) {
2525
clients := make(map[string]*grpc_client.Client, len(endpoints))
2626
for _, cfg := range endpoints {
27-
c, err := grpc_client.NewCLient(cfg.Address, cfg.Options...)
27+
c, err := grpc_client.NewCLient(context.Background(), cfg.Address, cfg.Options...)
2828
if err != nil {
2929
return nil, err
3030
}

0 commit comments

Comments
 (0)