Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Remove unused method from grpc handler #6580

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions plugin/storage/grpc/shared/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,6 @@ func NewGRPCHandler(impl *GRPCHandlerStorageImpl) *GRPCHandler {
return &GRPCHandler{impl: impl}
}

// NewGRPCHandler creates a handler given implementations grouped by plugin services.
func NewGRPCHandlerWithPlugins(
mainImpl StoragePlugin,
archiveImpl ArchiveStoragePlugin,
streamImpl StreamingSpanWriterPlugin,
) *GRPCHandler {
impl := &GRPCHandlerStorageImpl{
SpanReader: mainImpl.SpanReader,
SpanWriter: mainImpl.SpanWriter,
DependencyReader: mainImpl.DependencyReader,

ArchiveSpanReader: func() spanstore.Reader { return nil },
ArchiveSpanWriter: func() spanstore.Writer { return nil },
StreamingSpanWriter: func() spanstore.Writer { return nil },
}
if archiveImpl != nil {
impl.ArchiveSpanReader = archiveImpl.ArchiveSpanReader
impl.ArchiveSpanWriter = archiveImpl.ArchiveSpanWriter
}
if streamImpl != nil {
impl.StreamingSpanWriter = streamImpl.StreamingSpanWriter
}
return NewGRPCHandler(impl)
}

// Register registers the server as gRPC methods handler.
func (s *GRPCHandler) Register(ss *grpc.Server, hs *health.Server) error {
storage_v1.RegisterSpanReaderPluginServer(ss, s)
Expand Down
44 changes: 24 additions & 20 deletions plugin/storage/grpc/shared/grpc_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func withGRPCServer(fn func(r *grpcServerTest)) {
depReader := new(dependencyStoreMocks.Reader)
streamWriter := new(spanStoreMocks.Writer)

impl := &mockStoragePlugin{
mockPlugin := &mockStoragePlugin{
spanReader: spanReader,
spanWriter: spanWriter,
archiveReader: archiveReader,
Expand All @@ -80,11 +80,32 @@ func withGRPCServer(fn func(r *grpcServerTest)) {
streamWriter: streamWriter,
}

handler := NewGRPCHandlerWithPlugins(impl, impl, impl)
impl := &GRPCHandlerStorageImpl{
SpanReader: func() spanstore.Reader {
return mockPlugin.spanReader
},
SpanWriter: func() spanstore.Writer {
return mockPlugin.spanWriter
},
DependencyReader: func() dependencystore.Reader {
return mockPlugin.depsReader
},
ArchiveSpanReader: func() spanstore.Reader {
return mockPlugin.archiveReader
},
ArchiveSpanWriter: func() spanstore.Writer {
return mockPlugin.archiveWriter
},
StreamingSpanWriter: func() spanstore.Writer {
return mockPlugin.streamWriter
},
}

handler := NewGRPCHandler(impl)
defer handler.Close(context.Background(), &storage_v1.CloseWriterRequest{})
r := &grpcServerTest{
server: handler,
impl: impl,
impl: mockPlugin,
}
fn(r)
}
Expand Down Expand Up @@ -433,20 +454,3 @@ func TestGRPCServerCapabilities_NoStreamWriter(t *testing.T) {
assert.Equal(t, expected, capabilities)
})
}

func TestNewGRPCHandlerWithPlugins_Nils(t *testing.T) {
spanReader := new(spanStoreMocks.Reader)
spanWriter := new(spanStoreMocks.Writer)
depReader := new(dependencyStoreMocks.Reader)

impl := &mockStoragePlugin{
spanReader: spanReader,
spanWriter: spanWriter,
depsReader: depReader,
}

handler := NewGRPCHandlerWithPlugins(impl, nil, nil)
assert.Nil(t, handler.impl.ArchiveSpanReader())
assert.Nil(t, handler.impl.ArchiveSpanWriter())
assert.Nil(t, handler.impl.StreamingSpanWriter())
}
Loading