From 975f8fb24ce181407608e6e854331953817ba8a1 Mon Sep 17 00:00:00 2001 From: chahatsagarmain Date: Mon, 7 Oct 2024 15:56:55 +0530 Subject: [PATCH] host interface Signed-off-by: chahatsagarmain --- plugin/storage/grpc/factory.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/plugin/storage/grpc/factory.go b/plugin/storage/grpc/factory.go index 9ac64f455a9..bab8a609602 100644 --- a/plugin/storage/grpc/factory.go +++ b/plugin/storage/grpc/factory.go @@ -48,10 +48,22 @@ 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. @@ -59,10 +71,6 @@ 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, @@ -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