Skip to content

Commit

Permalink
added host to contructor
Browse files Browse the repository at this point in the history
Signed-off-by: chahatsagarmain <[email protected]>
  • Loading branch information
chahatsagarmain committed Oct 12, 2024
1 parent c026ceb commit 5532991
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/extension/jaegerstorage/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (s *storageExt) Start(_ context.Context, _ component.Host) error {
factory, err = badger.NewFactoryWithConfig(*cfg.Badger, mf, s.telset.Logger)
case cfg.GRPC != nil:
//nolint: contextcheck
factory, err = grpc.NewFactoryWithConfig(*cfg.GRPC, mf, s.telset.Logger)
factory, err = grpc.NewFactoryWithConfig(*cfg.GRPC, mf, s.telset.Logger, grpc.NewHost())
case cfg.Cassandra != nil:
factory, err = cassandra.NewFactoryWithConfig(*cfg.Cassandra, mf, s.telset.Logger)
case cfg.Elasticsearch != nil:
Expand Down
7 changes: 5 additions & 2 deletions plugin/storage/grpc/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Factory struct {
config Config
services *ClientPluginServices
remoteConn *grpc.ClientConn
host component.Host
}

type host struct {
Expand Down Expand Up @@ -76,9 +77,11 @@ func NewFactoryWithConfig(
cfg Config,
metricsFactory metrics.Factory,
logger *zap.Logger,
host component.Host,
) (*Factory, error) {
f := NewFactory()
f.config = cfg
f.host = host
if err := f.Initialize(metricsFactory, logger); err != nil {
return nil, err
}
Expand Down Expand Up @@ -115,8 +118,8 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger)
for _, opt := range opts {
clientOpts = append(clientOpts, configgrpc.WithGrpcDialOption(opt))
}
host := NewHost()
return f.config.ToClientConn(context.Background(), host, telset, clientOpts...)

return f.config.ToClientConn(context.Background(), f.host, telset, clientOpts...)
}

var err error
Expand Down
6 changes: 3 additions & 3 deletions plugin/storage/grpc/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestNewFactoryError(t *testing.T) {
},
}
t.Run("with_config", func(t *testing.T) {
_, err := NewFactoryWithConfig(*cfg, metrics.NullFactory, zap.NewNop())
_, err := NewFactoryWithConfig(*cfg, metrics.NullFactory, zap.NewNop(), NewHost())
require.Error(t, err)
assert.Contains(t, err.Error(), "authenticator")
})
Expand All @@ -121,7 +121,7 @@ func TestNewFactoryError(t *testing.T) {

t.Run("client", func(t *testing.T) {
// this is a silly test to verify handling of error from grpc.NewClient, which cannot be induced via params.
f, err := NewFactoryWithConfig(Config{}, metrics.NullFactory, zap.NewNop())
f, err := NewFactoryWithConfig(Config{}, metrics.NullFactory, zap.NewNop(), NewHost())
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, f.Close()) })
newClientFn := func(_ ...grpc.DialOption) (conn *grpc.ClientConn, err error) {
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestGRPCStorageFactoryWithConfig(t *testing.T) {
Enabled: true,
},
}
f, err := NewFactoryWithConfig(cfg, metrics.NullFactory, zap.NewNop())
f, err := NewFactoryWithConfig(cfg, metrics.NullFactory, zap.NewNop(), NewHost())
require.NoError(t, err)
require.NoError(t, f.Close())
}
Expand Down

0 comments on commit 5532991

Please sign in to comment.