Skip to content

Commit

Permalink
Make grpc client creation more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
cluttrdev committed Feb 26, 2024
1 parent e5e8943 commit fbd0bf9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions grpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Client struct {
metrics *grpcprom.ClientMetrics
}

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

opts = append(opts,
Expand All @@ -31,7 +31,7 @@ func NewCLient(addr string, opts ...grpc.DialOption) (*Client, error) {
),
)

conn, err := grpc.Dial(addr, opts...)
conn, err := grpc.DialContext(ctx, target, opts...)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type EndpointConfig struct {
func New(endpoints []EndpointConfig) (*Exporter, error) {
clients := make(map[string]*grpc_client.Client, len(endpoints))
for _, cfg := range endpoints {
c, err := grpc_client.NewCLient(cfg.Address, cfg.Options...)
c, err := grpc_client.NewCLient(context.Background(), cfg.Address, cfg.Options...)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit fbd0bf9

Please sign in to comment.