Skip to content

Commit

Permalink
pkg/loop: swap out deprecated grpc API
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Aug 20, 2024
1 parent c0750da commit bfac4aa
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
3 changes: 1 addition & 2 deletions pkg/loop/internal/net/test/simple_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ func (v *Broker) DialWithOptions(id uint32, opts ...grpc.DialOption) (conn *grpc
return nil, fmt.Errorf("listener with id %d does not exist", id)
}
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
//TODO https://smartcontract-it.atlassian.net/browse/BCF-3290
return grpc.Dial(l.Addr().String(), opts...) //nolint:staticcheck
return grpc.NewClient(l.Addr().String(), opts...)
}

// NextId implements net.Broker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@ func (lst *loopServerTester) GetConn(t *testing.T) *grpc.ClientConn {
return lst.conn
}

//TODO https://smartcontract-it.atlassian.net/browse/BCF-3290
//nolint:staticcheck
conn, err := grpc.Dial("bufnet",
conn, err := grpc.NewClient("bufnet",
grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { return lst.lis.Dial() }),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock())
grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(t, err)
lst.conn = conn
return conn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ func (p *ProviderServer) Close() error {
}

func (p *ProviderServer) GetConn() (grpc.ClientConnInterface, error) {
//TODO https://smartcontract-it.atlassian.net/browse/BCF-3290
cc, err := grpc.Dial(p.lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials())) //nolint:staticcheck
cc, err := grpc.NewClient(p.lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
p.conns = append(p.conns, cc)
return cc, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/loop/internal/test/grpc_scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ func NewGRPCScaffold[T Client, S any](t *testing.T, serverFn SetupGRPCServer[S],
require.NoError(t, grpcServer.Serve(lis))
}()

//TODO https://smartcontract-it.atlassian.net/browse/BCF-3290
conn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials())) //nolint:staticcheck
conn, err := grpc.NewClient(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(t, err, "failed to dial %s", lis.Addr().String())
t.Cleanup(func() { require.NoError(t, conn.Close(), "failed to close connection") })

Expand Down
4 changes: 1 addition & 3 deletions pkg/loop/telem.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ func SetupTracing(config TracingConfig) (err error) {
creds = insecure.NewCredentials()
}

//TODO https://smartcontract-it.atlassian.net/browse/BCF-3290
//nolint:staticcheck
conn, err := grpc.DialContext(ctx, config.CollectorTarget,
conn, err := grpc.NewClient(config.CollectorTarget,
// Note the potential use of insecure transport here. TLS is recommended in production.
grpc.WithTransportCredentials(creds),
grpc.WithContextDialer(func(ctx context.Context, s string) (net.Conn, error) {
Expand Down

0 comments on commit bfac4aa

Please sign in to comment.