Skip to content

Commit

Permalink
Declare all interfaces each factory implements (#4967)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Part of #4963
- Follow up to #4834

## Description of the changes
- Explicitly declare all interfaces each factory implements
- Move these declarations to the main file for visibility

## How was this change tested?
- CI

Signed-off-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
yurishkuro authored Nov 26, 2023
1 parent aac1513 commit 4096fe9
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 35 deletions.
11 changes: 10 additions & 1 deletion plugin/storage/badger/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
depStore "github.com/jaegertracing/jaeger/plugin/storage/badger/dependencystore"
badgerSampling "github.com/jaegertracing/jaeger/plugin/storage/badger/samplingstore"
badgerStore "github.com/jaegertracing/jaeger/plugin/storage/badger/spanstore"
"github.com/jaegertracing/jaeger/storage"
"github.com/jaegertracing/jaeger/storage/dependencystore"
"github.com/jaegertracing/jaeger/storage/samplingstore"
"github.com/jaegertracing/jaeger/storage/spanstore"
Expand All @@ -43,9 +44,17 @@ const (
lastValueLogCleanedName = "badger_storage_valueloggc_last_run"
)

var (
var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)

// TODO badger could implement archive storage
// _ storage.ArchiveFactory = (*Factory)(nil)

// TODO CreateLock function is missing
// Being fixed in https://github.com/jaegertracing/jaeger/pull/4966
// _ storage.SamplingStoreFactory = (*Factory)(nil)
)

// Factory implements storage.Factory for Badger backend.
Expand Down
6 changes: 6 additions & 0 deletions plugin/storage/blackhole/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ import (
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/storage"
"github.com/jaegertracing/jaeger/storage/dependencystore"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ storage.ArchiveFactory = (*Factory)(nil)
)

// Factory implements storage.Factory and creates blackhole storage components.
type Factory struct {
metricsFactory metrics.Factory
Expand Down
9 changes: 6 additions & 3 deletions plugin/storage/cassandra/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ const (
archiveStorageConfig = "cassandra-archive"
)

var (
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ storage.ArchiveFactory = (*Factory)(nil)
_ storage.SamplingStoreFactory = (*Factory)(nil)
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
)

// Factory implements storage.Factory for Cassandra backend.
Expand Down
6 changes: 0 additions & 6 deletions plugin/storage/cassandra/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ import (
"github.com/jaegertracing/jaeger/pkg/config"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/jaegertracing/jaeger/storage"
)

var (
_ storage.Factory = new(Factory)
_ storage.ArchiveFactory = new(Factory)
)

type mockSessionBuilder struct {
Expand Down
9 changes: 6 additions & 3 deletions plugin/storage/es/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
esDepStore "github.com/jaegertracing/jaeger/plugin/storage/es/dependencystore"
"github.com/jaegertracing/jaeger/plugin/storage/es/mappings"
esSpanStore "github.com/jaegertracing/jaeger/plugin/storage/es/spanstore"
"github.com/jaegertracing/jaeger/storage"
"github.com/jaegertracing/jaeger/storage/dependencystore"
"github.com/jaegertracing/jaeger/storage/spanstore"
)
Expand All @@ -47,9 +48,11 @@ const (
archiveNamespace = "es-archive"
)

var (
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ storage.ArchiveFactory = (*Factory)(nil)
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
)

// Factory implements storage.Factory for Elasticsearch backend.
Expand Down
3 changes: 0 additions & 3 deletions plugin/storage/es/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ import (
"github.com/jaegertracing/jaeger/pkg/es/mocks"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/jaegertracing/jaeger/storage"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

var _ storage.Factory = new(Factory)

var mockEsServerResponse = []byte(`
{
"Version": {
Expand Down
8 changes: 5 additions & 3 deletions plugin/storage/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ func AllSamplingStorageTypes() []string {
return backends
}

var (
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ storage.ArchiveFactory = (*Factory)(nil)
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
)

// Factory implements storage.Factory interface as a meta-factory for storage components.
Expand Down
5 changes: 0 additions & 5 deletions plugin/storage/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ import (
spanStoreMocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
)

var (
_ storage.Factory = new(Factory)
_ storage.ArchiveFactory = new(Factory)
)

func defaultCfg() FactoryConfig {
return FactoryConfig{
SpanWriterTypes: []string{cassandraStorageType},
Expand Down
8 changes: 5 additions & 3 deletions plugin/storage/grpc/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ import (
"github.com/jaegertracing/jaeger/storage/spanstore"
)

var (
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ storage.ArchiveFactory = (*Factory)(nil)
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
)

// Factory implements storage.Factory and creates storage components backed by a storage plugin.
Expand Down
2 changes: 0 additions & 2 deletions plugin/storage/grpc/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import (
spanStoreMocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
)

var _ storage.Factory = new(Factory)

type mockPluginBuilder struct {
plugin *mockPlugin
writerType string
Expand Down
4 changes: 3 additions & 1 deletion plugin/storage/kafka/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import (
"github.com/jaegertracing/jaeger/pkg/kafka/producer"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/plugin"
"github.com/jaegertracing/jaeger/storage"
"github.com/jaegertracing/jaeger/storage/dependencystore"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

var (
var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
)
Expand Down
4 changes: 0 additions & 4 deletions plugin/storage/kafka/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ import (
"github.com/jaegertracing/jaeger/pkg/config"
kafkaConfig "github.com/jaegertracing/jaeger/pkg/kafka/producer"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/storage"
)

// Checks that Kafka Factory conforms to storage.Factory API
var _ storage.Factory = new(Factory)

type mockProducerBuilder struct {
kafkaConfig.Configuration
err error
Expand Down
8 changes: 7 additions & 1 deletion plugin/storage/memory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ import (
"github.com/jaegertracing/jaeger/pkg/memory/config"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/plugin"
"github.com/jaegertracing/jaeger/storage"
"github.com/jaegertracing/jaeger/storage/dependencystore"
"github.com/jaegertracing/jaeger/storage/samplingstore"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

var _ plugin.Configurable = (*Factory)(nil)
var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ storage.ArchiveFactory = (*Factory)(nil)
_ storage.SamplingStoreFactory = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
)

// Factory implements storage.Factory and creates storage components backed by memory store.
type Factory struct {
Expand Down

0 comments on commit 4096fe9

Please sign in to comment.