Skip to content

Commit

Permalink
host interface
Browse files Browse the repository at this point in the history
Signed-off-by: chahatsagarmain <[email protected]>
  • Loading branch information
chahatsagarmain committed Oct 7, 2024
1 parent f0edd49 commit 975f8fb
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions plugin/storage/grpc/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,29 @@ type Factory struct {
remoteConn *grpc.ClientConn
}

type nopHost struct{}
type host struct {
extensions map[component.ID]component.Component
}

func NewNopHost() component.Host {
return &nopHost{}
func NewHost() component.Host {
return &host{
extensions: make(map[component.ID]component.Component),
}
}

func (h *host) GetExtensions() map[component.ID]component.Component {
return h.extensions
}

func (h *host) AddExtensions(id component.ID, ext component.Component) {
h.extensions[id] = ext
}

// NewFactory creates a new Factory.
func NewFactory() *Factory {
return &Factory{}
}

func (*nopHost) GetExtensions() map[component.ID]component.Component {
return nil
}

// NewFactoryWithConfig is used from jaeger(v2).
func NewFactoryWithConfig(
cfg Config,
Expand Down Expand Up @@ -107,8 +115,8 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger)
for _, opt := range opts {
clientOpts = append(clientOpts, configgrpc.WithGrpcDialOption(opt))
}
noophost := NewNopHost()
return f.config.ToClientConn(context.Background(), noophost, telset, clientOpts...)
host := NewHost()
return f.config.ToClientConn(context.Background(), host, telset, clientOpts...)
}

var err error
Expand Down

0 comments on commit 975f8fb

Please sign in to comment.