From ecc509138fe0b92e63106464f3c1ace299a781e3 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 26 Sep 2020 03:32:47 +0300 Subject: [PATCH] Grpc plugin archive storage support (#2317) * Grpc plugin archive storage support Signed-off-by: Andrew Putilov * Introduce service PluginCapabilities Migrate from ArchiveSupportedRequest to CapabilitiesRequest Signed-off-by: Andrew Putilov * Add comments Signed-off-by: Andrew Putilov * Introduce PluginServices Signed-off-by: Andrew Putilov * Format imports, insert copyright Signed-off-by: Andrew Putilov * Bubble up error on Capabilities() call Signed-off-by: Andrew Putilov * Add empty_test.go Signed-off-by: Andrew Putilov * Remove ArchiveReader, ArchiveWriter Signed-off-by: Andrew Putilov * Pass config.PluginServices to grpc.Serve Signed-off-by: Andrew Putilov * Introduce shared.ArchiveReader/ArchiveWriter Signed-off-by: Andrew Putilov * Improve ArchiveReader/ArchiveWriter according PR comments Signed-off-by: Andrew Putilov * Test fixes Signed-off-by: Andrew Putilov * Validate plugin type Signed-off-by: Andrew Putilov * Add context to WriteSpan method Signed-off-by: Andrew Putilov * Return plugin capabilities according ArchiveImpl property Signed-off-by: Andrew Putilov * Apply changes from master Signed-off-by: Andrew Putilov * Extract PluginServices to shared package, introduce ClientPluginServices on plugin client side Signed-off-by: Andrew Putilov * Improve error text Signed-off-by: Andrew Putilov * Rebase-related updates Signed-off-by: Andrew Putilov * Rename memoryStore to memoryStorePlugin Signed-off-by: Andrew Putilov * minor clean-up - make internal types private - add interface validations - wrap errors with %w Signed-off-by: Yuri Shkuro * Return codes.NotFound in grpc plugin on missing trace Signed-off-by: Andrew Putilov * make fmt Signed-off-by: Yuri Shkuro * Handle spanstore.ErrTraceNotFound in grpcServer.GetArchiveTrace Signed-off-by: Andrew Putilov * Undo unnecessary change Signed-off-by: Yuri Shkuro * Increase factory code coverage Signed-off-by: Andrew Putilov * Trigger codecov again Signed-off-by: Andrew Putilov * Disable coverage in plugin/storage/grpc/config/ Signed-off-by: Yuri Shkuro Co-authored-by: Yuri Shkuro Co-authored-by: Yuri Shkuro --- examples/memstore-plugin/main.go | 29 +- plugin/storage/grpc/config/.nocover | 1 + plugin/storage/grpc/config/config.go | 38 +- plugin/storage/grpc/config/empty_test.go | 15 - plugin/storage/grpc/factory.go | 41 +- plugin/storage/grpc/factory_test.go | 149 +++- plugin/storage/grpc/grpc.go | 10 +- .../storage/grpc/mocks/PluginCapabilities.go | 51 ++ plugin/storage/grpc/options.go | 1 - plugin/storage/grpc/options_test.go | 3 +- plugin/storage/grpc/proto/storage.proto | 24 + plugin/storage/grpc/shared/archive.go | 90 +++ plugin/storage/grpc/shared/archive_test.go | 112 +++ plugin/storage/grpc/shared/grpc_client.go | 80 +- .../storage/grpc/shared/grpc_client_test.go | 172 ++++- plugin/storage/grpc/shared/grpc_server.go | 47 +- .../storage/grpc/shared/grpc_server_test.go | 188 ++++- plugin/storage/grpc/shared/interface.go | 23 + plugin/storage/grpc/shared/plugin.go | 20 +- .../mocks/ArchiveSpanReaderPluginClient.go | 48 ++ .../mocks/ArchiveSpanReaderPluginServer.go | 27 + ...eSpanReaderPlugin_GetArchiveTraceClient.go | 137 ++++ ...eSpanReaderPlugin_GetArchiveTraceServer.go | 108 +++ .../mocks/ArchiveSpanWriterPluginClient.go | 48 ++ .../mocks/ArchiveSpanWriterPluginServer.go | 38 + .../mocks/PluginCapabilitiesClient.go | 48 ++ .../mocks/PluginCapabilitiesServer.go | 38 + proto-gen/storage_v1/storage.pb.go | 690 ++++++++++++++++-- 28 files changed, 2129 insertions(+), 147 deletions(-) create mode 100644 plugin/storage/grpc/config/.nocover delete mode 100644 plugin/storage/grpc/config/empty_test.go create mode 100644 plugin/storage/grpc/mocks/PluginCapabilities.go create mode 100644 plugin/storage/grpc/shared/archive.go create mode 100644 plugin/storage/grpc/shared/archive_test.go create mode 100644 proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginClient.go create mode 100644 proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginServer.go create mode 100644 proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceClient.go create mode 100644 proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceServer.go create mode 100644 proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginClient.go create mode 100644 proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginServer.go create mode 100644 proto-gen/storage_v1/mocks/PluginCapabilitiesClient.go create mode 100644 proto-gen/storage_v1/mocks/PluginCapabilitiesServer.go diff --git a/examples/memstore-plugin/main.go b/examples/memstore-plugin/main.go index 494e78545ad..76018ef9155 100644 --- a/examples/memstore-plugin/main.go +++ b/examples/memstore-plugin/main.go @@ -22,6 +22,7 @@ import ( "github.com/spf13/viper" "github.com/jaegertracing/jaeger/plugin/storage/grpc" + "github.com/jaegertracing/jaeger/plugin/storage/grpc/shared" "github.com/jaegertracing/jaeger/plugin/storage/memory" "github.com/jaegertracing/jaeger/storage/dependencystore" "github.com/jaegertracing/jaeger/storage/spanstore" @@ -45,21 +46,37 @@ func main() { opts := memory.Options{} opts.InitFromViper(v) - grpc.Serve(&memoryStore{store: memory.NewStore()}) + plugin := &memoryStorePlugin{ + store: memory.NewStore(), + archiveStore: memory.NewStore(), + } + grpc.Serve(&shared.PluginServices{ + Store: plugin, + ArchiveStore: plugin, + }) } -type memoryStore struct { - store *memory.Store +type memoryStorePlugin struct { + store *memory.Store + archiveStore *memory.Store } -func (ns *memoryStore) DependencyReader() dependencystore.Reader { +func (ns *memoryStorePlugin) DependencyReader() dependencystore.Reader { return ns.store } -func (ns *memoryStore) SpanReader() spanstore.Reader { +func (ns *memoryStorePlugin) SpanReader() spanstore.Reader { return ns.store } -func (ns *memoryStore) SpanWriter() spanstore.Writer { +func (ns *memoryStorePlugin) SpanWriter() spanstore.Writer { return ns.store } + +func (ns *memoryStorePlugin) ArchiveSpanReader() spanstore.Reader { + return ns.archiveStore +} + +func (ns *memoryStorePlugin) ArchiveSpanWriter() spanstore.Writer { + return ns.archiveStore +} diff --git a/plugin/storage/grpc/config/.nocover b/plugin/storage/grpc/config/.nocover new file mode 100644 index 00000000000..5504c0198c2 --- /dev/null +++ b/plugin/storage/grpc/config/.nocover @@ -0,0 +1 @@ +requires gRPC plugin binary diff --git a/plugin/storage/grpc/config/config.go b/plugin/storage/grpc/config/config.go index fb144a07317..6ee887d39c9 100644 --- a/plugin/storage/grpc/config/config.go +++ b/plugin/storage/grpc/config/config.go @@ -32,13 +32,19 @@ type Configuration struct { PluginLogLevel string `yaml:"log-level" mapstructure:"log_level"` } +// ClientPluginServices defines services plugin can expose and its capabilities +type ClientPluginServices struct { + shared.PluginServices + Capabilities shared.PluginCapabilities +} + // PluginBuilder is used to create storage plugins. Implemented by Configuration. type PluginBuilder interface { - Build() (shared.StoragePlugin, error) + Build() (*ClientPluginServices, error) } -// Build instantiates a StoragePlugin -func (c *Configuration) Build() (shared.StoragePlugin, error) { +// Build instantiates a PluginServices +func (c *Configuration) Build() (*ClientPluginServices, error) { // #nosec G204 cmd := exec.Command(c.PluginBinary, "--config", c.PluginConfigurationFile) @@ -60,18 +66,36 @@ func (c *Configuration) Build() (shared.StoragePlugin, error) { rpcClient, err := client.Client() if err != nil { - return nil, fmt.Errorf("error attempting to connect to plugin rpc client: %s", err) + return nil, fmt.Errorf("error attempting to connect to plugin rpc client: %w", err) } raw, err := rpcClient.Dispense(shared.StoragePluginIdentifier) if err != nil { - return nil, fmt.Errorf("unable to retrieve storage plugin instance: %s", err) + return nil, fmt.Errorf("unable to retrieve storage plugin instance: %w", err) } + // in practice, the type of `raw` is *shared.grpcClient, and type casts below cannot fail storagePlugin, ok := raw.(shared.StoragePlugin) if !ok { - return nil, fmt.Errorf("unexpected type for plugin \"%s\"", shared.StoragePluginIdentifier) + return nil, fmt.Errorf("unable to cast %T to shared.StoragePlugin for plugin \"%s\"", + raw, shared.StoragePluginIdentifier) + } + archiveStoragePlugin, ok := raw.(shared.ArchiveStoragePlugin) + if !ok { + return nil, fmt.Errorf("unable to cast %T to shared.ArchiveStoragePlugin for plugin \"%s\"", + raw, shared.StoragePluginIdentifier) + } + capabilities, ok := raw.(shared.PluginCapabilities) + if !ok { + return nil, fmt.Errorf("unable to cast %T to shared.PluginCapabilities for plugin \"%s\"", + raw, shared.StoragePluginIdentifier) } - return storagePlugin, nil + return &ClientPluginServices{ + PluginServices: shared.PluginServices{ + Store: storagePlugin, + ArchiveStore: archiveStoragePlugin, + }, + Capabilities: capabilities, + }, nil } diff --git a/plugin/storage/grpc/config/empty_test.go b/plugin/storage/grpc/config/empty_test.go deleted file mode 100644 index 6e632bd9e87..00000000000 --- a/plugin/storage/grpc/config/empty_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2018 The Jaeger Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package config diff --git a/plugin/storage/grpc/factory.go b/plugin/storage/grpc/factory.go index 504f9371ec5..e5ee5dc7855 100644 --- a/plugin/storage/grpc/factory.go +++ b/plugin/storage/grpc/factory.go @@ -24,6 +24,7 @@ import ( "github.com/jaegertracing/jaeger/plugin/storage/grpc/config" "github.com/jaegertracing/jaeger/plugin/storage/grpc/shared" + "github.com/jaegertracing/jaeger/storage" "github.com/jaegertracing/jaeger/storage/dependencystore" "github.com/jaegertracing/jaeger/storage/spanstore" ) @@ -36,7 +37,9 @@ type Factory struct { builder config.PluginBuilder - store shared.StoragePlugin + store shared.StoragePlugin + archiveStore shared.ArchiveStoragePlugin + capabilities shared.PluginCapabilities } // NewFactory creates a new Factory. @@ -65,12 +68,14 @@ func (f *Factory) InitFromOptions(opts Options) { func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error { f.metricsFactory, f.logger = metricsFactory, logger - store, err := f.builder.Build() + services, err := f.builder.Build() if err != nil { return fmt.Errorf("grpc-plugin builder failed to create a store: %w", err) } - f.store = store + f.store = services.Store + f.archiveStore = services.ArchiveStore + f.capabilities = services.Capabilities logger.Info("External plugin storage configuration", zap.Any("configuration", f.options.Configuration)) return nil } @@ -89,3 +94,33 @@ func (f *Factory) CreateSpanWriter() (spanstore.Writer, error) { func (f *Factory) CreateDependencyReader() (dependencystore.Reader, error) { return f.store.DependencyReader(), nil } + +// CreateArchiveSpanReader implements storage.ArchiveFactory +func (f *Factory) CreateArchiveSpanReader() (spanstore.Reader, error) { + if f.capabilities == nil { + return nil, storage.ErrArchiveStorageNotSupported + } + capabilities, err := f.capabilities.Capabilities() + if err != nil { + return nil, err + } + if capabilities == nil || !capabilities.ArchiveSpanReader { + return nil, storage.ErrArchiveStorageNotSupported + } + return f.archiveStore.ArchiveSpanReader(), nil +} + +// CreateArchiveSpanWriter implements storage.ArchiveFactory +func (f *Factory) CreateArchiveSpanWriter() (spanstore.Writer, error) { + if f.capabilities == nil { + return nil, storage.ErrArchiveStorageNotSupported + } + capabilities, err := f.capabilities.Capabilities() + if err != nil { + return nil, err + } + if capabilities == nil || !capabilities.ArchiveSpanWriter { + return nil, storage.ErrArchiveStorageNotSupported + } + return f.archiveStore.ArchiveSpanWriter(), nil +} diff --git a/plugin/storage/grpc/factory_test.go b/plugin/storage/grpc/factory_test.go index 5adeeab4991..b8b295435fd 100644 --- a/plugin/storage/grpc/factory_test.go +++ b/plugin/storage/grpc/factory_test.go @@ -26,6 +26,7 @@ import ( "github.com/jaegertracing/jaeger/pkg/config" grpcConfig "github.com/jaegertracing/jaeger/plugin/storage/grpc/config" + "github.com/jaegertracing/jaeger/plugin/storage/grpc/mocks" "github.com/jaegertracing/jaeger/plugin/storage/grpc/shared" "github.com/jaegertracing/jaeger/storage" "github.com/jaegertracing/jaeger/storage/dependencystore" @@ -41,19 +42,45 @@ type mockPluginBuilder struct { err error } -func (b *mockPluginBuilder) Build() (shared.StoragePlugin, error) { +func (b *mockPluginBuilder) Build() (*grpcConfig.ClientPluginServices, error) { if b.err != nil { return nil, b.err } - return b.plugin, nil + + services := &grpcConfig.ClientPluginServices{ + PluginServices: shared.PluginServices{ + Store: b.plugin, + ArchiveStore: b.plugin, + }, + } + if b.plugin.capabilities != nil { + services.Capabilities = b.plugin + } + + return services, nil } type mockPlugin struct { spanReader spanstore.Reader spanWriter spanstore.Writer + archiveReader spanstore.Reader + archiveWriter spanstore.Writer + capabilities shared.PluginCapabilities dependencyReader dependencystore.Reader } +func (mp *mockPlugin) Capabilities() (*shared.Capabilities, error) { + return mp.capabilities.Capabilities() +} + +func (mp *mockPlugin) ArchiveSpanReader() spanstore.Reader { + return mp.archiveReader +} + +func (mp *mockPlugin) ArchiveSpanWriter() spanstore.Writer { + return mp.archiveWriter +} + func (mp *mockPlugin) SpanReader() spanstore.Reader { return mp.spanReader } @@ -84,6 +111,9 @@ func TestGRPCStorageFactory(t *testing.T) { plugin: &mockPlugin{ spanWriter: new(spanStoreMocks.Writer), spanReader: new(spanStoreMocks.Reader), + archiveWriter: new(spanStoreMocks.Writer), + archiveReader: new(spanStoreMocks.Reader), + capabilities: new(mocks.PluginCapabilities), dependencyReader: new(dependencyStoreMocks.Reader), }, } @@ -101,14 +131,125 @@ func TestGRPCStorageFactory(t *testing.T) { assert.Equal(t, f.store.DependencyReader(), depReader) } +func TestGRPCStorageFactory_Capabilities(t *testing.T) { + f := NewFactory() + v := viper.New() + f.InitFromViper(v) + + capabilities := new(mocks.PluginCapabilities) + capabilities.On("Capabilities"). + Return(&shared.Capabilities{ + ArchiveSpanReader: true, + ArchiveSpanWriter: true, + }, nil) + + f.builder = &mockPluginBuilder{ + plugin: &mockPlugin{ + capabilities: capabilities, + archiveWriter: new(spanStoreMocks.Writer), + archiveReader: new(spanStoreMocks.Reader), + }, + } + assert.NoError(t, f.Initialize(metrics.NullFactory, zap.NewNop())) + + assert.NotNil(t, f.store) + reader, err := f.CreateArchiveSpanReader() + assert.NoError(t, err) + assert.NotNil(t, reader) + writer, err := f.CreateArchiveSpanWriter() + assert.NoError(t, err) + assert.NotNil(t, writer) +} + +func TestGRPCStorageFactory_CapabilitiesDisabled(t *testing.T) { + f := NewFactory() + v := viper.New() + f.InitFromViper(v) + + capabilities := new(mocks.PluginCapabilities) + capabilities.On("Capabilities"). + Return(&shared.Capabilities{ + ArchiveSpanReader: false, + ArchiveSpanWriter: false, + }, nil) + + f.builder = &mockPluginBuilder{ + plugin: &mockPlugin{ + capabilities: capabilities, + archiveWriter: new(spanStoreMocks.Writer), + archiveReader: new(spanStoreMocks.Reader), + }, + } + assert.NoError(t, f.Initialize(metrics.NullFactory, zap.NewNop())) + + assert.NotNil(t, f.store) + reader, err := f.CreateArchiveSpanReader() + assert.EqualError(t, err, storage.ErrArchiveStorageNotSupported.Error()) + assert.Nil(t, reader) + writer, err := f.CreateArchiveSpanWriter() + assert.EqualError(t, err, storage.ErrArchiveStorageNotSupported.Error()) + assert.Nil(t, writer) +} + +func TestGRPCStorageFactory_CapabilitiesError(t *testing.T) { + f := NewFactory() + v := viper.New() + f.InitFromViper(v) + + capabilities := new(mocks.PluginCapabilities) + customError := errors.New("made-up error") + capabilities.On("Capabilities"). + Return(nil, customError) + + f.builder = &mockPluginBuilder{ + plugin: &mockPlugin{ + capabilities: capabilities, + archiveWriter: new(spanStoreMocks.Writer), + archiveReader: new(spanStoreMocks.Reader), + }, + } + assert.NoError(t, f.Initialize(metrics.NullFactory, zap.NewNop())) + + assert.NotNil(t, f.store) + reader, err := f.CreateArchiveSpanReader() + assert.EqualError(t, err, customError.Error()) + assert.Nil(t, reader) + writer, err := f.CreateArchiveSpanWriter() + assert.EqualError(t, err, customError.Error()) + assert.Nil(t, writer) +} + +func TestGRPCStorageFactory_CapabilitiesNil(t *testing.T) { + f := NewFactory() + v := viper.New() + f.InitFromViper(v) + + f.builder = &mockPluginBuilder{ + plugin: &mockPlugin{ + archiveWriter: new(spanStoreMocks.Writer), + archiveReader: new(spanStoreMocks.Reader), + }, + } + assert.NoError(t, f.Initialize(metrics.NullFactory, zap.NewNop())) + + assert.NotNil(t, f.store) + reader, err := f.CreateArchiveSpanReader() + assert.Equal(t, err, storage.ErrArchiveStorageNotSupported) + assert.Nil(t, reader) + writer, err := f.CreateArchiveSpanWriter() + assert.Equal(t, err, storage.ErrArchiveStorageNotSupported) + assert.Nil(t, writer) +} + func TestWithConfiguration(t *testing.T) { f := NewFactory() v, command := config.Viperize(f.AddFlags) - command.ParseFlags([]string{ + err := command.ParseFlags([]string{ + "--grpc-storage-plugin.log-level=debug", "--grpc-storage-plugin.binary=noop-grpc-plugin", "--grpc-storage-plugin.configuration-file=config.json", - "--grpc-storage-plugin.log-level=debug", }) + assert.NoError(t, err) f.InitFromViper(v) assert.Equal(t, f.options.Configuration.PluginBinary, "noop-grpc-plugin") assert.Equal(t, f.options.Configuration.PluginConfigurationFile, "config.json") diff --git a/plugin/storage/grpc/grpc.go b/plugin/storage/grpc/grpc.go index b693e62d459..562d1957391 100644 --- a/plugin/storage/grpc/grpc.go +++ b/plugin/storage/grpc/grpc.go @@ -22,19 +22,21 @@ import ( ) // Serve creates a plugin configuration using the implementation of StoragePlugin and then serves it. -func Serve(implementation shared.StoragePlugin) { - ServeWithGRPCServer(implementation, plugin.DefaultGRPCServer) +func Serve(services *shared.PluginServices) { + ServeWithGRPCServer(services, plugin.DefaultGRPCServer) } // ServeWithGRPCServer creates a plugin configuration using the implementation of StoragePlugin and // function to create grpcServer, and then serves it. -func ServeWithGRPCServer(implementation shared.StoragePlugin, grpcServer func([]grpc.ServerOption) *grpc.Server) { +func ServeWithGRPCServer(services *shared.PluginServices, grpcServer func([]grpc.ServerOption) *grpc.Server, +) { plugin.Serve(&plugin.ServeConfig{ HandshakeConfig: shared.Handshake, VersionedPlugins: map[int]plugin.PluginSet{ 1: map[string]plugin.Plugin{ shared.StoragePluginIdentifier: &shared.StorageGRPCPlugin{ - Impl: implementation, + Impl: services.Store, + ArchiveImpl: services.ArchiveStore, }, }, }, diff --git a/plugin/storage/grpc/mocks/PluginCapabilities.go b/plugin/storage/grpc/mocks/PluginCapabilities.go new file mode 100644 index 00000000000..7d72d623594 --- /dev/null +++ b/plugin/storage/grpc/mocks/PluginCapabilities.go @@ -0,0 +1,51 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +// Copyright (c) 2020 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + + "github.com/jaegertracing/jaeger/plugin/storage/grpc/shared" +) + +// PluginCapabilities is an autogenerated mock type for the PluginCapabilities type +type PluginCapabilities struct { + mock.Mock +} + +// Capabilities provides a mock function with given fields: +func (_m *PluginCapabilities) Capabilities() (*shared.Capabilities, error) { + ret := _m.Called() + + var r0 *shared.Capabilities + if rf, ok := ret.Get(0).(func() *shared.Capabilities); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*shared.Capabilities) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/plugin/storage/grpc/options.go b/plugin/storage/grpc/options.go index b5c6d6f805a..7938a9dde9c 100644 --- a/plugin/storage/grpc/options.go +++ b/plugin/storage/grpc/options.go @@ -47,5 +47,4 @@ func (opt *Options) InitFromViper(v *viper.Viper) { opt.Configuration.PluginBinary = v.GetString(pluginBinary) opt.Configuration.PluginConfigurationFile = v.GetString(pluginConfigurationFile) opt.Configuration.PluginLogLevel = v.GetString(pluginLogLevel) - } diff --git a/plugin/storage/grpc/options_test.go b/plugin/storage/grpc/options_test.go index be0e3611b67..5e563c5c15c 100644 --- a/plugin/storage/grpc/options_test.go +++ b/plugin/storage/grpc/options_test.go @@ -25,11 +25,12 @@ import ( func TestOptionsWithFlags(t *testing.T) { opts := &Options{} v, command := config.Viperize(opts.AddFlags) - command.ParseFlags([]string{ + err := command.ParseFlags([]string{ "--grpc-storage-plugin.binary=noop-grpc-plugin", "--grpc-storage-plugin.configuration-file=config.json", "--grpc-storage-plugin.log-level=debug", }) + assert.NoError(t, err) opts.InitFromViper(v) assert.Equal(t, opts.Configuration.PluginBinary, "noop-grpc-plugin") diff --git a/plugin/storage/grpc/proto/storage.proto b/plugin/storage/grpc/proto/storage.proto index bd85d263948..739f31d1c94 100644 --- a/plugin/storage/grpc/proto/storage.proto +++ b/plugin/storage/grpc/proto/storage.proto @@ -148,7 +148,31 @@ service SpanReaderPlugin { rpc FindTraceIDs(FindTraceIDsRequest) returns (FindTraceIDsResponse); } +service ArchiveSpanWriterPlugin { + // spanstore/Writer + rpc WriteArchiveSpan(WriteSpanRequest) returns (WriteSpanResponse); +} + +service ArchiveSpanReaderPlugin { + // spanstore/Reader + rpc GetArchiveTrace(GetTraceRequest) returns (stream SpansResponseChunk); +} + service DependenciesReaderPlugin { // dependencystore/Reader rpc GetDependencies(GetDependenciesRequest) returns (GetDependenciesResponse); } + +// empty; extensible in the future +message CapabilitiesRequest { + +} + +message CapabilitiesResponse { + bool archiveSpanReader = 1; + bool archiveSpanWriter = 2; +} + +service PluginCapabilities { + rpc Capabilities(CapabilitiesRequest) returns (CapabilitiesResponse); +} \ No newline at end of file diff --git a/plugin/storage/grpc/shared/archive.go b/plugin/storage/grpc/shared/archive.go new file mode 100644 index 00000000000..cd74f038c0f --- /dev/null +++ b/plugin/storage/grpc/shared/archive.go @@ -0,0 +1,90 @@ +// Copyright (c) 2020 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package shared + +import ( + "context" + "errors" + "fmt" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/proto-gen/storage_v1" + "github.com/jaegertracing/jaeger/storage/spanstore" +) + +var ( + _ spanstore.Reader = (*archiveReader)(nil) + _ spanstore.Writer = (*archiveWriter)(nil) +) + +// archiveReader wraps storage_v1.ArchiveSpanReaderPluginClient into spanstore.Reader +type archiveReader struct { + client storage_v1.ArchiveSpanReaderPluginClient +} + +// ArchiveWriter wraps storage_v1.ArchiveSpanWriterPluginClient into spanstore.Writer +type archiveWriter struct { + client storage_v1.ArchiveSpanWriterPluginClient +} + +// GetTrace takes a traceID and returns a Trace associated with that traceID from Archive Storage +func (r *archiveReader) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error) { + stream, err := r.client.GetArchiveTrace(upgradeContextWithBearerToken(ctx), &storage_v1.GetTraceRequest{ + TraceID: traceID, + }) + if status.Code(err) == codes.NotFound { + return nil, spanstore.ErrTraceNotFound + } + if err != nil { + return nil, fmt.Errorf("plugin error: %w", err) + } + + return readTrace(stream) +} + +// GetServices not used in archiveReader +func (r *archiveReader) GetServices(ctx context.Context) ([]string, error) { + return nil, errors.New("GetServices not implemented") +} + +// GetOperations not used in archiveReader +func (r *archiveReader) GetOperations(ctx context.Context, query spanstore.OperationQueryParameters) ([]spanstore.Operation, error) { + return nil, errors.New("GetOperations not implemented") +} + +// FindTraces not used in archiveReader +func (r *archiveReader) FindTraces(ctx context.Context, query *spanstore.TraceQueryParameters) ([]*model.Trace, error) { + return nil, errors.New("FindTraces not implemented") +} + +// FindTraceIDs not used in archiveReader +func (r *archiveReader) FindTraceIDs(ctx context.Context, query *spanstore.TraceQueryParameters) ([]model.TraceID, error) { + return nil, errors.New("FindTraceIDs not implemented") +} + +// WriteSpan saves the span into Archive Storage +func (w *archiveWriter) WriteSpan(ctx context.Context, span *model.Span) error { + _, err := w.client.WriteArchiveSpan(ctx, &storage_v1.WriteSpanRequest{ + Span: span, + }) + if err != nil { + return fmt.Errorf("plugin error: %w", err) + } + + return nil +} diff --git a/plugin/storage/grpc/shared/archive_test.go b/plugin/storage/grpc/shared/archive_test.go new file mode 100644 index 00000000000..bad217c90e9 --- /dev/null +++ b/plugin/storage/grpc/shared/archive_test.go @@ -0,0 +1,112 @@ +// Copyright (c) 2020 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package shared + +import ( + "context" + "io" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/proto-gen/storage_v1" + "github.com/jaegertracing/jaeger/proto-gen/storage_v1/mocks" + "github.com/jaegertracing/jaeger/storage/spanstore" +) + +func TestArchiveWriter_WriteSpan(t *testing.T) { + mockSpan := &model.Span{ + TraceID: mockTraceID, + SpanID: model.NewSpanID(1), + Process: &model.Process{}, + } + + archiveSpanWriter := new(mocks.ArchiveSpanWriterPluginClient) + archiveSpanWriter.On("WriteArchiveSpan", mock.Anything, &storage_v1.WriteSpanRequest{Span: mockSpan}). + Return(&storage_v1.WriteSpanResponse{}, nil) + writer := &archiveWriter{client: archiveSpanWriter} + + err := writer.WriteSpan(context.Background(), mockSpan) + assert.NoError(t, err) +} + +func TestArchiveReader_GetTrace(t *testing.T) { + mockTraceID := model.NewTraceID(0, 123456) + mockSpan := model.Span{ + TraceID: mockTraceID, + SpanID: model.NewSpanID(1), + Process: &model.Process{}, + } + expected := &model.Trace{ + Spans: []*model.Span{&mockSpan}, + } + + traceClient := new(mocks.ArchiveSpanReaderPlugin_GetArchiveTraceClient) + traceClient.On("Recv").Return(&storage_v1.SpansResponseChunk{ + Spans: []model.Span{mockSpan}, + }, nil).Once() + traceClient.On("Recv").Return(nil, io.EOF) + + archiveSpanReader := new(mocks.ArchiveSpanReaderPluginClient) + archiveSpanReader.On("GetArchiveTrace", mock.Anything, &storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }).Return(traceClient, nil) + reader := &archiveReader{client: archiveSpanReader} + + trace, err := reader.GetTrace(context.Background(), mockTraceID) + assert.NoError(t, err) + assert.Equal(t, expected, trace) +} + +func TestArchiveReaderGetTrace_NoTrace(t *testing.T) { + mockTraceID := model.NewTraceID(0, 123456) + + archiveSpanReader := new(mocks.ArchiveSpanReaderPluginClient) + archiveSpanReader.On("GetArchiveTrace", mock.Anything, &storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }).Return(nil, status.Errorf(codes.NotFound, "")) + reader := &archiveReader{client: archiveSpanReader} + + _, err := reader.GetTrace(context.Background(), mockTraceID) + assert.Equal(t, spanstore.ErrTraceNotFound, err) +} + +func TestArchiveReader_FindTraceIDs(t *testing.T) { + reader := archiveReader{client: &mocks.ArchiveSpanReaderPluginClient{}} + _, err := reader.FindTraceIDs(context.Background(), nil) + assert.Error(t, err) +} + +func TestArchiveReader_FindTraces(t *testing.T) { + reader := archiveReader{client: &mocks.ArchiveSpanReaderPluginClient{}} + _, err := reader.FindTraces(context.Background(), nil) + assert.Error(t, err) +} + +func TestArchiveReader_GetOperations(t *testing.T) { + reader := archiveReader{client: &mocks.ArchiveSpanReaderPluginClient{}} + _, err := reader.GetOperations(context.Background(), spanstore.OperationQueryParameters{}) + assert.Error(t, err) +} + +func TestArchiveReader_GetServices(t *testing.T) { + reader := archiveReader{client: &mocks.ArchiveSpanReaderPluginClient{}} + _, err := reader.GetServices(context.Background()) + assert.Error(t, err) +} diff --git a/plugin/storage/grpc/shared/grpc_client.go b/plugin/storage/grpc/shared/grpc_client.go index a0b2c841498..ec09629b7ef 100644 --- a/plugin/storage/grpc/shared/grpc_client.go +++ b/plugin/storage/grpc/shared/grpc_client.go @@ -20,6 +20,7 @@ import ( "io" "time" + "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" @@ -29,11 +30,20 @@ import ( "github.com/jaegertracing/jaeger/storage/spanstore" ) +var ( + _ StoragePlugin = (*grpcClient)(nil) + _ ArchiveStoragePlugin = (*grpcClient)(nil) + _ PluginCapabilities = (*grpcClient)(nil) +) + // grpcClient implements shared.StoragePlugin and reads/writes spans and dependencies type grpcClient struct { - readerClient storage_v1.SpanReaderPluginClient - writerClient storage_v1.SpanWriterPluginClient - depsReaderClient storage_v1.DependenciesReaderPluginClient + readerClient storage_v1.SpanReaderPluginClient + writerClient storage_v1.SpanWriterPluginClient + archiveReaderClient storage_v1.ArchiveSpanReaderPluginClient + archiveWriterClient storage_v1.ArchiveSpanWriterPluginClient + capabilitiesClient storage_v1.PluginCapabilitiesClient + depsReaderClient storage_v1.DependenciesReaderPluginClient } // upgradeContextWithBearerToken turns the context into a gRPC outgoing context with bearer token @@ -65,32 +75,27 @@ func (c *grpcClient) SpanWriter() spanstore.Writer { return c } +func (c *grpcClient) ArchiveSpanReader() spanstore.Reader { + return &archiveReader{client: c.archiveReaderClient} +} + +func (c *grpcClient) ArchiveSpanWriter() spanstore.Writer { + return &archiveWriter{client: c.archiveWriterClient} +} + // GetTrace takes a traceID and returns a Trace associated with that traceID func (c *grpcClient) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error) { stream, err := c.readerClient.GetTrace(upgradeContextWithBearerToken(ctx), &storage_v1.GetTraceRequest{ TraceID: traceID, }) + if status.Code(err) == codes.NotFound { + return nil, spanstore.ErrTraceNotFound + } if err != nil { return nil, fmt.Errorf("plugin error: %w", err) } - trace := model.Trace{} - for received, err := stream.Recv(); err != io.EOF; received, err = stream.Recv() { - if err != nil { - if s, _ := status.FromError(err); s != nil { - if s.Message() == spanstore.ErrTraceNotFound.Error() { - return nil, spanstore.ErrTraceNotFound - } - } - return nil, fmt.Errorf("grpc stream error: %w", err) - } - - for i := range received.Spans { - trace.Spans = append(trace.Spans, &received.Spans[i]) - } - } - - return &trace, nil + return readTrace(stream) } // GetServices returns a list of all known services @@ -217,3 +222,38 @@ func (c *grpcClient) GetDependencies(ctx context.Context, endTs time.Time, lookb return resp.Dependencies, nil } + +func (c *grpcClient) Capabilities() (*Capabilities, error) { + capabilities, err := c.capabilitiesClient.Capabilities(context.Background(), &storage_v1.CapabilitiesRequest{}) + if status.Code(err) == codes.Unimplemented { + return &Capabilities{}, nil + } + if err != nil { + return nil, fmt.Errorf("plugin error: %w", err) + } + + return &Capabilities{ + ArchiveSpanReader: capabilities.ArchiveSpanReader, + ArchiveSpanWriter: capabilities.ArchiveSpanWriter, + }, nil +} + +func readTrace(stream storage_v1.SpanReaderPlugin_GetTraceClient) (*model.Trace, error) { + trace := model.Trace{} + for received, err := stream.Recv(); err != io.EOF; received, err = stream.Recv() { + if err != nil { + if s, _ := status.FromError(err); s != nil { + if s.Message() == spanstore.ErrTraceNotFound.Error() { + return nil, spanstore.ErrTraceNotFound + } + } + return nil, fmt.Errorf("grpc stream error: %w", err) + } + + for i := range received.Spans { + trace.Spans = append(trace.Spans, &received.Spans[i]) + } + } + + return &trace, nil +} diff --git a/plugin/storage/grpc/shared/grpc_client_test.go b/plugin/storage/grpc/shared/grpc_client_test.go index 244ca35b8af..872968a68c5 100644 --- a/plugin/storage/grpc/shared/grpc_client_test.go +++ b/plugin/storage/grpc/shared/grpc_client_test.go @@ -23,6 +23,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" @@ -69,26 +70,38 @@ var ( ) type grpcClientTest struct { - client *grpcClient - spanReader *grpcMocks.SpanReaderPluginClient - spanWriter *grpcMocks.SpanWriterPluginClient - depsReader *grpcMocks.DependenciesReaderPluginClient + client *grpcClient + spanReader *grpcMocks.SpanReaderPluginClient + spanWriter *grpcMocks.SpanWriterPluginClient + archiveReader *grpcMocks.ArchiveSpanReaderPluginClient + archiveWriter *grpcMocks.ArchiveSpanWriterPluginClient + capabilities *grpcMocks.PluginCapabilitiesClient + depsReader *grpcMocks.DependenciesReaderPluginClient } func withGRPCClient(fn func(r *grpcClientTest)) { spanReader := new(grpcMocks.SpanReaderPluginClient) + archiveReader := new(grpcMocks.ArchiveSpanReaderPluginClient) spanWriter := new(grpcMocks.SpanWriterPluginClient) + archiveWriter := new(grpcMocks.ArchiveSpanWriterPluginClient) depReader := new(grpcMocks.DependenciesReaderPluginClient) + capabilities := new(grpcMocks.PluginCapabilitiesClient) r := &grpcClientTest{ client: &grpcClient{ - readerClient: spanReader, - writerClient: spanWriter, - depsReaderClient: depReader, + readerClient: spanReader, + writerClient: spanWriter, + archiveReaderClient: archiveReader, + archiveWriterClient: archiveWriter, + capabilitiesClient: capabilities, + depsReaderClient: depReader, }, - spanReader: spanReader, - spanWriter: spanWriter, - depsReader: depReader, + spanReader: spanReader, + spanWriter: spanWriter, + archiveReader: archiveReader, + archiveWriter: archiveWriter, + depsReader: depReader, + capabilities: capabilities, } fn(r) } @@ -192,10 +205,10 @@ func TestGRPCClientGetTrace_NoTrace(t *testing.T) { withGRPCClient(func(r *grpcClientTest) { r.spanReader.On("GetTrace", mock.Anything, &storage_v1.GetTraceRequest{ TraceID: mockTraceID, - }).Return(nil, spanstore.ErrTraceNotFound) + }).Return(nil, status.Errorf(codes.NotFound, "")) s, err := r.client.GetTrace(context.Background(), mockTraceID) - assert.Error(t, err) + assert.Equal(t, spanstore.ErrTraceNotFound, err) assert.Nil(t, s) }) } @@ -305,3 +318,138 @@ func TestGRPCClientGetDependencies(t *testing.T) { assert.Equal(t, deps, s) }) } + +func TestGrpcClientWriteArchiveSpan(t *testing.T) { + withGRPCClient(func(r *grpcClientTest) { + r.archiveWriter.On("WriteArchiveSpan", mock.Anything, &storage_v1.WriteSpanRequest{ + Span: &mockTraceSpans[0], + }).Return(&storage_v1.WriteSpanResponse{}, nil) + + err := r.client.ArchiveSpanWriter().WriteSpan(context.Background(), &mockTraceSpans[0]) + assert.NoError(t, err) + }) +} + +func TestGrpcClientWriteArchiveSpan_Error(t *testing.T) { + withGRPCClient(func(r *grpcClientTest) { + r.archiveWriter.On("WriteArchiveSpan", mock.Anything, &storage_v1.WriteSpanRequest{ + Span: &mockTraceSpans[0], + }).Return(nil, status.Error(codes.Internal, "internal error")) + + err := r.client.ArchiveSpanWriter().WriteSpan(context.Background(), &mockTraceSpans[0]) + assert.Error(t, err) + }) +} + +func TestGrpcClientGetArchiveTrace(t *testing.T) { + withGRPCClient(func(r *grpcClientTest) { + traceClient := new(grpcMocks.ArchiveSpanReaderPlugin_GetArchiveTraceClient) + traceClient.On("Recv").Return(&storage_v1.SpansResponseChunk{ + Spans: mockTraceSpans, + }, nil).Once() + traceClient.On("Recv").Return(nil, io.EOF) + r.archiveReader.On("GetArchiveTrace", mock.Anything, &storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }).Return(traceClient, nil) + + var expectedSpans []*model.Span + for i := range mockTraceSpans { + expectedSpans = append(expectedSpans, &mockTraceSpans[i]) + } + + s, err := r.client.ArchiveSpanReader().GetTrace(context.Background(), mockTraceID) + assert.NoError(t, err) + assert.Equal(t, &model.Trace{ + Spans: expectedSpans, + }, s) + }) +} + +func TestGrpcClientGetArchiveTrace_StreamError(t *testing.T) { + withGRPCClient(func(r *grpcClientTest) { + traceClient := new(grpcMocks.ArchiveSpanReaderPlugin_GetArchiveTraceClient) + traceClient.On("Recv").Return(nil, errors.New("an error")) + r.archiveReader.On("GetArchiveTrace", mock.Anything, &storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }).Return(traceClient, nil) + + s, err := r.client.ArchiveSpanReader().GetTrace(context.Background(), mockTraceID) + assert.Error(t, err) + assert.Nil(t, s) + }) +} + +func TestGrpcClientGetArchiveTrace_NoTrace(t *testing.T) { + withGRPCClient(func(r *grpcClientTest) { + r.archiveReader.On("GetArchiveTrace", mock.Anything, &storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }).Return(nil, spanstore.ErrTraceNotFound) + + s, err := r.client.ArchiveSpanReader().GetTrace(context.Background(), mockTraceID) + assert.Error(t, err) + assert.Nil(t, s) + }) +} + +func TestGrpcClientGetArchiveTrace_StreamErrorTraceNotFound(t *testing.T) { + withGRPCClient(func(r *grpcClientTest) { + traceClient := new(grpcMocks.ArchiveSpanReaderPlugin_GetArchiveTraceClient) + traceClient.On("Recv").Return(nil, spanstore.ErrTraceNotFound) + r.archiveReader.On("GetArchiveTrace", mock.Anything, &storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }).Return(traceClient, nil) + + s, err := r.client.ArchiveSpanReader().GetTrace(context.Background(), mockTraceID) + assert.Equal(t, spanstore.ErrTraceNotFound, err) + assert.Nil(t, s) + }) +} + +func TestGrpcClientCapabilities(t *testing.T) { + withGRPCClient(func(r *grpcClientTest) { + r.capabilities.On("Capabilities", mock.Anything, &storage_v1.CapabilitiesRequest{}). + Return(&storage_v1.CapabilitiesResponse{ArchiveSpanReader: true, ArchiveSpanWriter: true}, nil) + + capabilities, err := r.client.Capabilities() + assert.NoError(t, err) + assert.Equal(t, &Capabilities{ + ArchiveSpanReader: true, + ArchiveSpanWriter: true, + }, capabilities) + }) +} + +func TestGrpcClientCapabilities_NotSupported(t *testing.T) { + withGRPCClient(func(r *grpcClientTest) { + r.capabilities.On("Capabilities", mock.Anything, &storage_v1.CapabilitiesRequest{}). + Return(&storage_v1.CapabilitiesResponse{}, nil) + + capabilities, err := r.client.Capabilities() + assert.NoError(t, err) + assert.Equal(t, &Capabilities{ + ArchiveSpanReader: false, + ArchiveSpanWriter: false, + }, capabilities) + }) +} + +func TestGrpcClientCapabilities_MissingMethod(t *testing.T) { + withGRPCClient(func(r *grpcClientTest) { + r.capabilities.On("Capabilities", mock.Anything, &storage_v1.CapabilitiesRequest{}). + Return(nil, status.Error(codes.Unimplemented, "method not found")) + + capabilities, err := r.client.Capabilities() + assert.NoError(t, err) + assert.Equal(t, &Capabilities{}, capabilities) + }) +} + +func TestGrpcClientArchiveSupported_CommonGrpcError(t *testing.T) { + withGRPCClient(func(r *grpcClientTest) { + r.capabilities.On("Capabilities", mock.Anything, &storage_v1.CapabilitiesRequest{}). + Return(nil, status.Error(codes.Internal, "internal error")) + + _, err := r.client.Capabilities() + assert.Error(t, err) + }) +} diff --git a/plugin/storage/grpc/shared/grpc_server.go b/plugin/storage/grpc/shared/grpc_server.go index 4518908c825..488a17bf692 100644 --- a/plugin/storage/grpc/shared/grpc_server.go +++ b/plugin/storage/grpc/shared/grpc_server.go @@ -18,6 +18,9 @@ import ( "context" "fmt" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/proto-gen/storage_v1" "github.com/jaegertracing/jaeger/storage/spanstore" @@ -27,7 +30,8 @@ const spanBatchSize = 1000 // grpcServer implements shared.StoragePlugin and reads/writes spans and dependencies type grpcServer struct { - Impl StoragePlugin + Impl StoragePlugin + ArchiveImpl ArchiveStoragePlugin } // GetDependencies returns all interservice dependencies @@ -53,6 +57,9 @@ func (s *grpcServer) WriteSpan(ctx context.Context, r *storage_v1.WriteSpanReque // GetTrace takes a traceID and streams a Trace associated with that traceID func (s *grpcServer) GetTrace(r *storage_v1.GetTraceRequest, stream storage_v1.SpanReaderPlugin_GetTraceServer) error { trace, err := s.Impl.SpanReader().GetTrace(stream.Context(), r.TraceID) + if err == spanstore.ErrTraceNotFound { + return status.Errorf(codes.NotFound, spanstore.ErrTraceNotFound.Error()) + } if err != nil { return err } @@ -160,3 +167,41 @@ func (s *grpcServer) sendSpans(spans []*model.Span, sendFn func(*storage_v1.Span return nil } + +func (s *grpcServer) Capabilities(ctx context.Context, request *storage_v1.CapabilitiesRequest) (*storage_v1.CapabilitiesResponse, error) { + return &storage_v1.CapabilitiesResponse{ + ArchiveSpanReader: s.ArchiveImpl != nil, + ArchiveSpanWriter: s.ArchiveImpl != nil, + }, nil +} + +func (s *grpcServer) GetArchiveTrace(r *storage_v1.GetTraceRequest, stream storage_v1.ArchiveSpanReaderPlugin_GetArchiveTraceServer) error { + if s.ArchiveImpl == nil { + return status.Error(codes.Unimplemented, "not implemented") + } + trace, err := s.ArchiveImpl.ArchiveSpanReader().GetTrace(stream.Context(), r.TraceID) + if err == spanstore.ErrTraceNotFound { + return status.Errorf(codes.NotFound, spanstore.ErrTraceNotFound.Error()) + } + if err != nil { + return err + } + + err = s.sendSpans(trace.Spans, stream.Send) + if err != nil { + return err + } + + return nil +} + +func (s *grpcServer) WriteArchiveSpan(ctx context.Context, r *storage_v1.WriteSpanRequest) (*storage_v1.WriteSpanResponse, error) { + if s.ArchiveImpl == nil { + return nil, status.Error(codes.Unimplemented, "not implemented") + } + err := s.ArchiveImpl.ArchiveSpanWriter().WriteSpan(ctx, r.Span) + if err != nil { + return nil, err + } + return &storage_v1.WriteSpanResponse{}, nil +} diff --git a/plugin/storage/grpc/shared/grpc_server_test.go b/plugin/storage/grpc/shared/grpc_server_test.go index 17b39367b3b..fcd676874c0 100644 --- a/plugin/storage/grpc/shared/grpc_server_test.go +++ b/plugin/storage/grpc/shared/grpc_server_test.go @@ -16,11 +16,14 @@ package shared import ( "context" + "fmt" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/proto-gen/storage_v1" @@ -32,9 +35,19 @@ import ( ) type mockStoragePlugin struct { - spanReader *spanStoreMocks.Reader - spanWriter *spanStoreMocks.Writer - depsReader *dependencyStoreMocks.Reader + spanReader *spanStoreMocks.Reader + spanWriter *spanStoreMocks.Writer + archiveReader *spanStoreMocks.Reader + archiveWriter *spanStoreMocks.Writer + depsReader *dependencyStoreMocks.Reader +} + +func (plugin *mockStoragePlugin) ArchiveSpanReader() spanstore.Reader { + return plugin.archiveReader +} + +func (plugin *mockStoragePlugin) ArchiveSpanWriter() spanstore.Writer { + return plugin.archiveWriter } func (plugin *mockStoragePlugin) SpanReader() spanstore.Reader { @@ -57,17 +70,22 @@ type grpcServerTest struct { func withGRPCServer(fn func(r *grpcServerTest)) { spanReader := new(spanStoreMocks.Reader) spanWriter := new(spanStoreMocks.Writer) + archiveReader := new(spanStoreMocks.Reader) + archiveWriter := new(spanStoreMocks.Writer) depReader := new(dependencyStoreMocks.Reader) impl := &mockStoragePlugin{ - spanWriter: spanWriter, - spanReader: spanReader, - depsReader: depReader, + spanReader: spanReader, + spanWriter: spanWriter, + archiveReader: archiveReader, + archiveWriter: archiveWriter, + depsReader: depReader, } r := &grpcServerTest{ server: &grpcServer{ - Impl: impl, + Impl: impl, + ArchiveImpl: impl, }, impl: impl, } @@ -131,6 +149,21 @@ func TestGRPCServerGetTrace(t *testing.T) { }) } +func TestGRPCServerGetTrace_NotFound(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + traceSteam := new(grpcMocks.SpanReaderPlugin_GetTraceServer) + traceSteam.On("Context").Return(context.Background()) + + r.impl.spanReader.On("GetTrace", mock.Anything, mockTraceID). + Return(nil, spanstore.ErrTraceNotFound) + + err := r.server.GetTrace(&storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }, traceSteam) + assert.Equal(t, codes.NotFound, status.Code(err)) + }) +} + func TestGRPCServerFindTraces(t *testing.T) { withGRPCServer(func(r *grpcServerTest) { traceSteam := new(grpcMocks.SpanReaderPlugin_FindTracesServer) @@ -209,3 +242,144 @@ func TestGRPCServerGetDependencies(t *testing.T) { assert.Equal(t, &storage_v1.GetDependenciesResponse{Dependencies: deps}, s) }) } + +func TestGRPCServerGetArchiveTrace(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + traceSteam := new(grpcMocks.SpanReaderPlugin_GetTraceServer) + traceSteam.On("Context").Return(context.Background()) + traceSteam.On("Send", &storage_v1.SpansResponseChunk{Spans: mockTraceSpans}). + Return(nil) + + var traceSpans []*model.Span + for i := range mockTraceSpans { + traceSpans = append(traceSpans, &mockTraceSpans[i]) + } + r.impl.archiveReader.On("GetTrace", mock.Anything, mockTraceID). + Return(&model.Trace{Spans: traceSpans}, nil) + + err := r.server.GetArchiveTrace(&storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }, traceSteam) + assert.NoError(t, err) + }) +} + +func TestGRPCServerGetArchiveTrace_NotFound(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + traceSteam := new(grpcMocks.SpanReaderPlugin_GetTraceServer) + traceSteam.On("Context").Return(context.Background()) + + r.impl.archiveReader.On("GetTrace", mock.Anything, mockTraceID). + Return(nil, spanstore.ErrTraceNotFound) + + err := r.server.GetArchiveTrace(&storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }, traceSteam) + assert.Equal(t, codes.NotFound, status.Code(err)) + }) +} + +func TestGRPCServerGetArchiveTrace_Error(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + traceSteam := new(grpcMocks.SpanReaderPlugin_GetTraceServer) + traceSteam.On("Context").Return(context.Background()) + + r.impl.archiveReader.On("GetTrace", mock.Anything, mockTraceID). + Return(nil, fmt.Errorf("some error")) + + err := r.server.GetArchiveTrace(&storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }, traceSteam) + assert.Error(t, err) + }) +} + +func TestGRPCServerGetArchiveTrace_NoImpl(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + r.server.ArchiveImpl = nil + traceSteam := new(grpcMocks.SpanReaderPlugin_GetTraceServer) + + r.impl.archiveReader.On("GetTrace", mock.Anything, mockTraceID). + Return(nil, fmt.Errorf("some error")) + + err := r.server.GetArchiveTrace(&storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }, traceSteam) + assert.Equal(t, codes.Unimplemented, status.Code(err)) + }) +} + +func TestGRPCServerGetArchiveTrace_StreamError(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + traceSteam := new(grpcMocks.SpanReaderPlugin_GetTraceServer) + traceSteam.On("Context").Return(context.Background()) + traceSteam.On("Send", &storage_v1.SpansResponseChunk{Spans: mockTraceSpans}). + Return(fmt.Errorf("some error")) + + var traceSpans []*model.Span + for i := range mockTraceSpans { + traceSpans = append(traceSpans, &mockTraceSpans[i]) + } + r.impl.archiveReader.On("GetTrace", mock.Anything, mockTraceID). + Return(&model.Trace{Spans: traceSpans}, nil) + + err := r.server.GetArchiveTrace(&storage_v1.GetTraceRequest{ + TraceID: mockTraceID, + }, traceSteam) + assert.Error(t, err) + }) +} + +func TestGRPCServerWriteArchiveSpan_NoImpl(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + r.server.ArchiveImpl = nil + + _, err := r.server.WriteArchiveSpan(context.Background(), &storage_v1.WriteSpanRequest{ + Span: &mockTraceSpans[0], + }) + assert.Equal(t, codes.Unimplemented, status.Code(err)) + }) +} + +func TestGRPCServerWriteArchiveSpan(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + r.impl.archiveWriter.On("WriteSpan", mock.Anything, &mockTraceSpans[0]). + Return(nil) + + s, err := r.server.WriteArchiveSpan(context.Background(), &storage_v1.WriteSpanRequest{ + Span: &mockTraceSpans[0], + }) + assert.NoError(t, err) + assert.Equal(t, &storage_v1.WriteSpanResponse{}, s) + }) +} + +func TestGRPCServerWriteArchiveSpan_Error(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + r.impl.archiveWriter.On("WriteSpan", mock.Anything, &mockTraceSpans[0]). + Return(fmt.Errorf("some error")) + + _, err := r.server.WriteArchiveSpan(context.Background(), &storage_v1.WriteSpanRequest{ + Span: &mockTraceSpans[0], + }) + assert.Error(t, err) + }) +} + +func TestGRPCServerCapabilities(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + capabilities, err := r.server.Capabilities(context.Background(), &storage_v1.CapabilitiesRequest{}) + assert.NoError(t, err) + assert.Equal(t, &storage_v1.CapabilitiesResponse{ArchiveSpanReader: true, ArchiveSpanWriter: true}, capabilities) + }) +} + +func TestGRPCServerCapabilities_NoArchive(t *testing.T) { + withGRPCServer(func(r *grpcServerTest) { + r.server.ArchiveImpl = nil + + capabilities, err := r.server.Capabilities(context.Background(), &storage_v1.CapabilitiesRequest{}) + assert.NoError(t, err) + assert.Equal(t, &storage_v1.CapabilitiesResponse{ArchiveSpanReader: false, ArchiveSpanWriter: false}, capabilities) + }) +} diff --git a/plugin/storage/grpc/shared/interface.go b/plugin/storage/grpc/shared/interface.go index 111fea3ada0..89cc0049b81 100644 --- a/plugin/storage/grpc/shared/interface.go +++ b/plugin/storage/grpc/shared/interface.go @@ -41,3 +41,26 @@ type StoragePlugin interface { SpanWriter() spanstore.Writer DependencyReader() dependencystore.Reader } + +// ArchiveStoragePlugin is the interface we're exposing as a plugin. +type ArchiveStoragePlugin interface { + ArchiveSpanReader() spanstore.Reader + ArchiveSpanWriter() spanstore.Writer +} + +// PluginCapabilities allow expose plugin its capabilities. +type PluginCapabilities interface { + Capabilities() (*Capabilities, error) +} + +// Capabilities contains information about plugin capabilities +type Capabilities struct { + ArchiveSpanReader bool + ArchiveSpanWriter bool +} + +// PluginServices defines services plugin can expose +type PluginServices struct { + Store StoragePlugin + ArchiveStore ArchiveStoragePlugin +} diff --git a/plugin/storage/grpc/shared/plugin.go b/plugin/storage/grpc/shared/plugin.go index 26195d9467f..caae9f81a8c 100644 --- a/plugin/storage/grpc/shared/plugin.go +++ b/plugin/storage/grpc/shared/plugin.go @@ -31,14 +31,21 @@ type StorageGRPCPlugin struct { plugin.Plugin // Concrete implementation, This is only used for plugins that are written in Go. - Impl StoragePlugin + Impl StoragePlugin + ArchiveImpl ArchiveStoragePlugin } // GRPCServer implements plugin.GRPCPlugin. It is used by go-plugin to create a grpc plugin server. func (p *StorageGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error { - server := &grpcServer{Impl: p.Impl} + server := &grpcServer{ + Impl: p.Impl, + ArchiveImpl: p.ArchiveImpl, + } storage_v1.RegisterSpanReaderPluginServer(s, server) storage_v1.RegisterSpanWriterPluginServer(s, server) + storage_v1.RegisterArchiveSpanReaderPluginServer(s, server) + storage_v1.RegisterArchiveSpanWriterPluginServer(s, server) + storage_v1.RegisterPluginCapabilitiesServer(s, server) storage_v1.RegisterDependenciesReaderPluginServer(s, server) return nil } @@ -46,8 +53,11 @@ func (p *StorageGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server // GRPCClient implements plugin.GRPCPlugin. It is used by go-plugin to create a grpc plugin client. func (*StorageGRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { return &grpcClient{ - readerClient: storage_v1.NewSpanReaderPluginClient(c), - writerClient: storage_v1.NewSpanWriterPluginClient(c), - depsReaderClient: storage_v1.NewDependenciesReaderPluginClient(c), + readerClient: storage_v1.NewSpanReaderPluginClient(c), + writerClient: storage_v1.NewSpanWriterPluginClient(c), + archiveReaderClient: storage_v1.NewArchiveSpanReaderPluginClient(c), + archiveWriterClient: storage_v1.NewArchiveSpanWriterPluginClient(c), + capabilitiesClient: storage_v1.NewPluginCapabilitiesClient(c), + depsReaderClient: storage_v1.NewDependenciesReaderPluginClient(c), }, nil } diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginClient.go b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginClient.go new file mode 100644 index 00000000000..eaa8065f8fb --- /dev/null +++ b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginClient.go @@ -0,0 +1,48 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + grpc "google.golang.org/grpc" + + mock "github.com/stretchr/testify/mock" + + storage_v1 "github.com/jaegertracing/jaeger/proto-gen/storage_v1" +) + +// ArchiveSpanReaderPluginClient is an autogenerated mock type for the ArchiveSpanReaderPluginClient type +type ArchiveSpanReaderPluginClient struct { + mock.Mock +} + +// GetArchiveTrace provides a mock function with given fields: ctx, in, opts +func (_m *ArchiveSpanReaderPluginClient) GetArchiveTrace(ctx context.Context, in *storage_v1.GetTraceRequest, opts ...grpc.CallOption) (storage_v1.ArchiveSpanReaderPlugin_GetArchiveTraceClient, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 storage_v1.ArchiveSpanReaderPlugin_GetArchiveTraceClient + if rf, ok := ret.Get(0).(func(context.Context, *storage_v1.GetTraceRequest, ...grpc.CallOption) storage_v1.ArchiveSpanReaderPlugin_GetArchiveTraceClient); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(storage_v1.ArchiveSpanReaderPlugin_GetArchiveTraceClient) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *storage_v1.GetTraceRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginServer.go b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginServer.go new file mode 100644 index 00000000000..1b33b2a73e1 --- /dev/null +++ b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPluginServer.go @@ -0,0 +1,27 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import ( + storage_v1 "github.com/jaegertracing/jaeger/proto-gen/storage_v1" + mock "github.com/stretchr/testify/mock" +) + +// ArchiveSpanReaderPluginServer is an autogenerated mock type for the ArchiveSpanReaderPluginServer type +type ArchiveSpanReaderPluginServer struct { + mock.Mock +} + +// GetArchiveTrace provides a mock function with given fields: _a0, _a1 +func (_m *ArchiveSpanReaderPluginServer) GetArchiveTrace(_a0 *storage_v1.GetTraceRequest, _a1 storage_v1.ArchiveSpanReaderPlugin_GetArchiveTraceServer) error { + ret := _m.Called(_a0, _a1) + + var r0 error + if rf, ok := ret.Get(0).(func(*storage_v1.GetTraceRequest, storage_v1.ArchiveSpanReaderPlugin_GetArchiveTraceServer) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceClient.go b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceClient.go new file mode 100644 index 00000000000..b9b55519fc5 --- /dev/null +++ b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceClient.go @@ -0,0 +1,137 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + metadata "google.golang.org/grpc/metadata" + + storage_v1 "github.com/jaegertracing/jaeger/proto-gen/storage_v1" +) + +// ArchiveSpanReaderPlugin_GetArchiveTraceClient is an autogenerated mock type for the ArchiveSpanReaderPlugin_GetArchiveTraceClient type +type ArchiveSpanReaderPlugin_GetArchiveTraceClient struct { + mock.Mock +} + +// CloseSend provides a mock function with given fields: +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceClient) CloseSend() error { + ret := _m.Called() + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Context provides a mock function with given fields: +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceClient) Context() context.Context { + ret := _m.Called() + + var r0 context.Context + if rf, ok := ret.Get(0).(func() context.Context); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(context.Context) + } + } + + return r0 +} + +// Header provides a mock function with given fields: +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceClient) Header() (metadata.MD, error) { + ret := _m.Called() + + var r0 metadata.MD + if rf, ok := ret.Get(0).(func() metadata.MD); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(metadata.MD) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Recv provides a mock function with given fields: +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceClient) Recv() (*storage_v1.SpansResponseChunk, error) { + ret := _m.Called() + + var r0 *storage_v1.SpansResponseChunk + if rf, ok := ret.Get(0).(func() *storage_v1.SpansResponseChunk); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*storage_v1.SpansResponseChunk) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RecvMsg provides a mock function with given fields: m +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceClient) RecvMsg(m interface{}) error { + ret := _m.Called(m) + + var r0 error + if rf, ok := ret.Get(0).(func(interface{}) error); ok { + r0 = rf(m) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SendMsg provides a mock function with given fields: m +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceClient) SendMsg(m interface{}) error { + ret := _m.Called(m) + + var r0 error + if rf, ok := ret.Get(0).(func(interface{}) error); ok { + r0 = rf(m) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Trailer provides a mock function with given fields: +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceClient) Trailer() metadata.MD { + ret := _m.Called() + + var r0 metadata.MD + if rf, ok := ret.Get(0).(func() metadata.MD); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(metadata.MD) + } + } + + return r0 +} diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceServer.go b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceServer.go new file mode 100644 index 00000000000..7be83be16b6 --- /dev/null +++ b/proto-gen/storage_v1/mocks/ArchiveSpanReaderPlugin_GetArchiveTraceServer.go @@ -0,0 +1,108 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + metadata "google.golang.org/grpc/metadata" + + storage_v1 "github.com/jaegertracing/jaeger/proto-gen/storage_v1" +) + +// ArchiveSpanReaderPlugin_GetArchiveTraceServer is an autogenerated mock type for the ArchiveSpanReaderPlugin_GetArchiveTraceServer type +type ArchiveSpanReaderPlugin_GetArchiveTraceServer struct { + mock.Mock +} + +// Context provides a mock function with given fields: +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceServer) Context() context.Context { + ret := _m.Called() + + var r0 context.Context + if rf, ok := ret.Get(0).(func() context.Context); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(context.Context) + } + } + + return r0 +} + +// RecvMsg provides a mock function with given fields: m +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceServer) RecvMsg(m interface{}) error { + ret := _m.Called(m) + + var r0 error + if rf, ok := ret.Get(0).(func(interface{}) error); ok { + r0 = rf(m) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Send provides a mock function with given fields: _a0 +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceServer) Send(_a0 *storage_v1.SpansResponseChunk) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(*storage_v1.SpansResponseChunk) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SendHeader provides a mock function with given fields: _a0 +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceServer) SendHeader(_a0 metadata.MD) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(metadata.MD) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SendMsg provides a mock function with given fields: m +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceServer) SendMsg(m interface{}) error { + ret := _m.Called(m) + + var r0 error + if rf, ok := ret.Get(0).(func(interface{}) error); ok { + r0 = rf(m) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetHeader provides a mock function with given fields: _a0 +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceServer) SetHeader(_a0 metadata.MD) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(metadata.MD) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetTrailer provides a mock function with given fields: _a0 +func (_m *ArchiveSpanReaderPlugin_GetArchiveTraceServer) SetTrailer(_a0 metadata.MD) { + _m.Called(_a0) +} diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginClient.go b/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginClient.go new file mode 100644 index 00000000000..add833bbf4e --- /dev/null +++ b/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginClient.go @@ -0,0 +1,48 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + grpc "google.golang.org/grpc" + + mock "github.com/stretchr/testify/mock" + + storage_v1 "github.com/jaegertracing/jaeger/proto-gen/storage_v1" +) + +// ArchiveSpanWriterPluginClient is an autogenerated mock type for the ArchiveSpanWriterPluginClient type +type ArchiveSpanWriterPluginClient struct { + mock.Mock +} + +// WriteArchiveSpan provides a mock function with given fields: ctx, in, opts +func (_m *ArchiveSpanWriterPluginClient) WriteArchiveSpan(ctx context.Context, in *storage_v1.WriteSpanRequest, opts ...grpc.CallOption) (*storage_v1.WriteSpanResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *storage_v1.WriteSpanResponse + if rf, ok := ret.Get(0).(func(context.Context, *storage_v1.WriteSpanRequest, ...grpc.CallOption) *storage_v1.WriteSpanResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*storage_v1.WriteSpanResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *storage_v1.WriteSpanRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginServer.go b/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginServer.go new file mode 100644 index 00000000000..73c271ca14b --- /dev/null +++ b/proto-gen/storage_v1/mocks/ArchiveSpanWriterPluginServer.go @@ -0,0 +1,38 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + storage_v1 "github.com/jaegertracing/jaeger/proto-gen/storage_v1" + mock "github.com/stretchr/testify/mock" +) + +// ArchiveSpanWriterPluginServer is an autogenerated mock type for the ArchiveSpanWriterPluginServer type +type ArchiveSpanWriterPluginServer struct { + mock.Mock +} + +// WriteArchiveSpan provides a mock function with given fields: _a0, _a1 +func (_m *ArchiveSpanWriterPluginServer) WriteArchiveSpan(_a0 context.Context, _a1 *storage_v1.WriteSpanRequest) (*storage_v1.WriteSpanResponse, error) { + ret := _m.Called(_a0, _a1) + + var r0 *storage_v1.WriteSpanResponse + if rf, ok := ret.Get(0).(func(context.Context, *storage_v1.WriteSpanRequest) *storage_v1.WriteSpanResponse); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*storage_v1.WriteSpanResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *storage_v1.WriteSpanRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/proto-gen/storage_v1/mocks/PluginCapabilitiesClient.go b/proto-gen/storage_v1/mocks/PluginCapabilitiesClient.go new file mode 100644 index 00000000000..ad3962d351f --- /dev/null +++ b/proto-gen/storage_v1/mocks/PluginCapabilitiesClient.go @@ -0,0 +1,48 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + grpc "google.golang.org/grpc" + + mock "github.com/stretchr/testify/mock" + + storage_v1 "github.com/jaegertracing/jaeger/proto-gen/storage_v1" +) + +// PluginCapabilitiesClient is an autogenerated mock type for the PluginCapabilitiesClient type +type PluginCapabilitiesClient struct { + mock.Mock +} + +// Capabilities provides a mock function with given fields: ctx, in, opts +func (_m *PluginCapabilitiesClient) Capabilities(ctx context.Context, in *storage_v1.CapabilitiesRequest, opts ...grpc.CallOption) (*storage_v1.CapabilitiesResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *storage_v1.CapabilitiesResponse + if rf, ok := ret.Get(0).(func(context.Context, *storage_v1.CapabilitiesRequest, ...grpc.CallOption) *storage_v1.CapabilitiesResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*storage_v1.CapabilitiesResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *storage_v1.CapabilitiesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/proto-gen/storage_v1/mocks/PluginCapabilitiesServer.go b/proto-gen/storage_v1/mocks/PluginCapabilitiesServer.go new file mode 100644 index 00000000000..de589ba26a5 --- /dev/null +++ b/proto-gen/storage_v1/mocks/PluginCapabilitiesServer.go @@ -0,0 +1,38 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + storage_v1 "github.com/jaegertracing/jaeger/proto-gen/storage_v1" + mock "github.com/stretchr/testify/mock" +) + +// PluginCapabilitiesServer is an autogenerated mock type for the PluginCapabilitiesServer type +type PluginCapabilitiesServer struct { + mock.Mock +} + +// Capabilities provides a mock function with given fields: _a0, _a1 +func (_m *PluginCapabilitiesServer) Capabilities(_a0 context.Context, _a1 *storage_v1.CapabilitiesRequest) (*storage_v1.CapabilitiesResponse, error) { + ret := _m.Called(_a0, _a1) + + var r0 *storage_v1.CapabilitiesResponse + if rf, ok := ret.Get(0).(func(context.Context, *storage_v1.CapabilitiesRequest) *storage_v1.CapabilitiesResponse); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*storage_v1.CapabilitiesResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *storage_v1.CapabilitiesRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/proto-gen/storage_v1/storage.pb.go b/proto-gen/storage_v1/storage.pb.go index 20893a4fe29..0e7412a3c4b 100644 --- a/proto-gen/storage_v1/storage.pb.go +++ b/proto-gen/storage_v1/storage.pb.go @@ -796,6 +796,101 @@ func (m *FindTraceIDsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_FindTraceIDsResponse proto.InternalMessageInfo +// empty; extensible in the future +type CapabilitiesRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CapabilitiesRequest) Reset() { *m = CapabilitiesRequest{} } +func (m *CapabilitiesRequest) String() string { return proto.CompactTextString(m) } +func (*CapabilitiesRequest) ProtoMessage() {} +func (*CapabilitiesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0d2c4ccf1453ffdb, []int{15} +} +func (m *CapabilitiesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CapabilitiesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CapabilitiesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CapabilitiesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CapabilitiesRequest.Merge(m, src) +} +func (m *CapabilitiesRequest) XXX_Size() int { + return m.Size() +} +func (m *CapabilitiesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CapabilitiesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CapabilitiesRequest proto.InternalMessageInfo + +type CapabilitiesResponse struct { + ArchiveSpanReader bool `protobuf:"varint,1,opt,name=archiveSpanReader,proto3" json:"archiveSpanReader,omitempty"` + ArchiveSpanWriter bool `protobuf:"varint,2,opt,name=archiveSpanWriter,proto3" json:"archiveSpanWriter,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CapabilitiesResponse) Reset() { *m = CapabilitiesResponse{} } +func (m *CapabilitiesResponse) String() string { return proto.CompactTextString(m) } +func (*CapabilitiesResponse) ProtoMessage() {} +func (*CapabilitiesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0d2c4ccf1453ffdb, []int{16} +} +func (m *CapabilitiesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CapabilitiesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CapabilitiesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CapabilitiesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CapabilitiesResponse.Merge(m, src) +} +func (m *CapabilitiesResponse) XXX_Size() int { + return m.Size() +} +func (m *CapabilitiesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CapabilitiesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CapabilitiesResponse proto.InternalMessageInfo + +func (m *CapabilitiesResponse) GetArchiveSpanReader() bool { + if m != nil { + return m.ArchiveSpanReader + } + return false +} + +func (m *CapabilitiesResponse) GetArchiveSpanWriter() bool { + if m != nil { + return m.ArchiveSpanWriter + } + return false +} + func init() { proto.RegisterType((*GetDependenciesRequest)(nil), "jaeger.storage.v1.GetDependenciesRequest") golang_proto.RegisterType((*GetDependenciesRequest)(nil), "jaeger.storage.v1.GetDependenciesRequest") @@ -829,73 +924,83 @@ func init() { golang_proto.RegisterType((*FindTraceIDsRequest)(nil), "jaeger.storage.v1.FindTraceIDsRequest") proto.RegisterType((*FindTraceIDsResponse)(nil), "jaeger.storage.v1.FindTraceIDsResponse") golang_proto.RegisterType((*FindTraceIDsResponse)(nil), "jaeger.storage.v1.FindTraceIDsResponse") + proto.RegisterType((*CapabilitiesRequest)(nil), "jaeger.storage.v1.CapabilitiesRequest") + golang_proto.RegisterType((*CapabilitiesRequest)(nil), "jaeger.storage.v1.CapabilitiesRequest") + proto.RegisterType((*CapabilitiesResponse)(nil), "jaeger.storage.v1.CapabilitiesResponse") + golang_proto.RegisterType((*CapabilitiesResponse)(nil), "jaeger.storage.v1.CapabilitiesResponse") } func init() { proto.RegisterFile("storage.proto", fileDescriptor_0d2c4ccf1453ffdb) } func init() { golang_proto.RegisterFile("storage.proto", fileDescriptor_0d2c4ccf1453ffdb) } var fileDescriptor_0d2c4ccf1453ffdb = []byte{ - // 953 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4d, 0x73, 0xdb, 0x44, - 0x18, 0x46, 0x89, 0x5d, 0xdb, 0xaf, 0x9d, 0x92, 0x6c, 0x0c, 0x08, 0xd1, 0xda, 0x41, 0x90, 0x0f, - 0x98, 0x41, 0x26, 0xe6, 0x00, 0x03, 0x65, 0x00, 0x37, 0xa9, 0x27, 0x40, 0xa1, 0xa8, 0x19, 0x3a, - 0x43, 0x19, 0x34, 0xeb,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, - 0x1b, 0x6f, 0x9e, 0x0f, 0x92, 0xb5, 0xf4, 0xff, 0x9b, 0x97, 0xc1, 0x6c, 0x82, 0xdd, 0x3c, 0xd8, - 0x23, 0xa8, 0x67, 0xc2, 0x8e, 0xcc, 0x12, 0x9a, 0x29, 0xd5, 0x37, 0x56, 0x4b, 0x30, 0xb3, 0x63, - 0x7d, 0x57, 0x43, 0xdf, 0x43, 0xb3, 0xa0, 0xd5, 0x68, 0xb5, 0x9c, 0x7b, 0x4a, 0xe1, 0x8d, 0xb5, - 0x8b, 0x60, 0x6a, 0x2e, 0x23, 0x58, 0x98, 0x50, 0x52, 0xb4, 0x5e, 0xee, 0x38, 0x23, 0xfc, 0xc6, - 0xc6, 0xc5, 0x40, 0x15, 0xe3, 0x31, 0xc0, 0xd9, 0x12, 0xa0, 0xb2, 0x1e, 0xcf, 0xec, 0xc8, 0xe5, - 0xdb, 0xe3, 0x40, 0xab, 0xf8, 0xe0, 0xd0, 0xda, 0x79, 0xf4, 0x67, 0xef, 0xdc, 0x58, 0xbf, 0x10, - 0xa7, 0xa6, 0xfd, 0xb3, 0x06, 0xfa, 0xe4, 0xbf, 0x8c, 0xc2, 0xd4, 0xf7, 0xc5, 0xcf, 0x79, 0xf1, - 0x1a, 0xbd, 0x55, 0xde, 0x97, 0x92, 0x3f, 0x52, 0xc6, 0xdb, 0x97, 0x81, 0xca, 0x34, 0x06, 0xb7, - 0x9e, 0x9d, 0x76, 0xb4, 0x3f, 0x4f, 0x3b, 0xda, 0x3f, 0xa7, 0x1d, 0xed, 0x8f, 0x7f, 0x3b, 0xda, - 0x77, 0xa0, 0xbc, 0x9c, 0xf1, 0xe6, 0xe8, 0x86, 0x50, 0xba, 0xf7, 0xfe, 0x0f, 0x00, 0x00, 0xff, - 0xff, 0x22, 0xdc, 0xa9, 0x3a, 0x3c, 0x0a, 0x00, 0x00, + // 1051 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 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4, 0x97, 0x19, 0xe3, 0x81, 0xa1, 0x36, 0x00, 0xf5, 0x48, 0xf0, + 0x90, 0x78, 0x63, 0x6b, 0x98, 0x64, 0x50, 0xdd, 0x81, 0x7a, 0x46, 0x2a, 0xe2, 0xa6, 0x40, 0xd9, + 0x17, 0x32, 0x16, 0xb3, 0x8a, 0x9e, 0x9c, 0xd5, 0xfb, 0xd0, 0xe8, 0x91, 0xe0, 0x6b, 0x97, 0xf0, + 0x92, 0x49, 0x8a, 0x41, 0x86, 0x65, 0x81, 0x61, 0xce, 0x57, 0xf4, 0xf8, 0x88, 0x5e, 0x83, 0x4a, + 0x14, 0x87, 0xfe, 0xb1, 0x45, 0x0d, 0x96, 0xe2, 0x88, 0xce, 0xc5, 0xf4, 0x0b, 0x8b, 0x1a, 0xea, + 0x1d, 0xa8, 0x24, 0x5c, 0x08, 0x41, 0x89, 0x62, 0x3b, 0x26, 0x60, 0xdf, 0x67, 0x6b, 0xff, 0x04, + 0x37, 0x72, 0xce, 0x88, 0x17, 0x6c, 0xc2, 0x75, 0x27, 0x96, 0x7e, 0x85, 0xed, 0xe4, 0x1d, 0x39, + 0x29, 0xba, 0x03, 0x90, 0x48, 0x7c, 0x79, 0x81, 0xd5, 0xc7, 0x2d, 0x6d, 0xae, 0xd3, 0xb4, 0xc4, + 0x84, 0x9e, 0xc2, 0xab, 0xbf, 0x97, 0xa0, 0xc1, 0x22, 0xfd, 0x4d, 0x48, 0xbc, 0xe9, 0x03, 0xec, + 0x61, 0x9b, 0x04, 0xc4, 0xf3, 0xd1, 0xeb, 0x50, 0x13, 0xaf, 0xef, 0xa7, 0x1e, 0x54, 0x15, 0xb2, + 0xc8, 0x34, 0xda, 0x48, 0x79, 0xc8, 0x41, 0xfc, 0x71, 0x2b, 0x19, 0x0f, 0xd1, 0x3e, 0x94, 0x02, + 0x6c, 0xfa, 0xf2, 0x22, 0x73, 0x6d, 0xa7, 0xc0, 0xb5, 0x22, 0x07, 0xb4, 0x43, 0x6c, 0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3, 0x96, 0x53, 0xb6, 0xce, 0xc5, + 0x89, 0x6c, 0x4f, 0xe0, 0xe6, 0xdd, 0x7c, 0xb9, 0x89, 0x9c, 0xff, 0x20, 0xfe, 0x54, 0x52, 0xf7, + 0x57, 0x59, 0x67, 0xd3, 0x8c, 0xe5, 0x4c, 0xb5, 0x3d, 0x61, 0x7f, 0x34, 0xe2, 0xf6, 0xea, 0x8b, + 0xae, 0xf3, 0xb3, 0x04, 0x72, 0xf6, 0x2f, 0x2f, 0x65, 0xfc, 0x88, 0x19, 0x4f, 0x5f, 0xa3, 0xb7, + 0x8a, 0x8d, 0x17, 0xfc, 0xc8, 0x2a, 0x6f, 0x5f, 0x04, 0x2a, 0x22, 0x10, 0x02, 0xe2, 0x36, 0xd3, + 0xf3, 0x24, 0x4a, 0x79, 0xe6, 0x5c, 0x94, 0xf2, 0x82, 0xb9, 0x54, 0x98, 0xf2, 0xa2, 0x41, 0xd5, + 0xbd, 0xf5, 0xfc, 0xb4, 0x29, 0xfd, 0x79, 0xda, 0x94, 0xfe, 0x39, 0x6d, 0x4a, 0x7f, 0xfc, 0xdb, + 0x94, 0xbe, 0x03, 0xa1, 0xd2, 0x1f, 0xef, 0x0c, 0xae, 0xb1, 0x05, 0xf7, 0xfe, 0xff, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x84, 0x36, 0xed, 0x70, 0x33, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1225,6 +1330,165 @@ var _SpanReaderPlugin_serviceDesc = grpc.ServiceDesc{ Metadata: "storage.proto", } +// ArchiveSpanWriterPluginClient is the client API for ArchiveSpanWriterPlugin service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ArchiveSpanWriterPluginClient interface { + // spanstore/Writer + WriteArchiveSpan(ctx context.Context, in *WriteSpanRequest, opts ...grpc.CallOption) (*WriteSpanResponse, error) +} + +type archiveSpanWriterPluginClient struct { + cc *grpc.ClientConn +} + +func NewArchiveSpanWriterPluginClient(cc *grpc.ClientConn) ArchiveSpanWriterPluginClient { + return &archiveSpanWriterPluginClient{cc} +} + +func (c *archiveSpanWriterPluginClient) WriteArchiveSpan(ctx context.Context, in *WriteSpanRequest, opts ...grpc.CallOption) (*WriteSpanResponse, error) { + out := new(WriteSpanResponse) + err := c.cc.Invoke(ctx, "/jaeger.storage.v1.ArchiveSpanWriterPlugin/WriteArchiveSpan", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ArchiveSpanWriterPluginServer is the server API for ArchiveSpanWriterPlugin service. +type ArchiveSpanWriterPluginServer interface { + // spanstore/Writer + WriteArchiveSpan(context.Context, *WriteSpanRequest) (*WriteSpanResponse, error) +} + +func RegisterArchiveSpanWriterPluginServer(s *grpc.Server, srv ArchiveSpanWriterPluginServer) { + s.RegisterService(&_ArchiveSpanWriterPlugin_serviceDesc, srv) +} + +func _ArchiveSpanWriterPlugin_WriteArchiveSpan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WriteSpanRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ArchiveSpanWriterPluginServer).WriteArchiveSpan(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/jaeger.storage.v1.ArchiveSpanWriterPlugin/WriteArchiveSpan", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ArchiveSpanWriterPluginServer).WriteArchiveSpan(ctx, req.(*WriteSpanRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _ArchiveSpanWriterPlugin_serviceDesc = grpc.ServiceDesc{ + ServiceName: "jaeger.storage.v1.ArchiveSpanWriterPlugin", + HandlerType: (*ArchiveSpanWriterPluginServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "WriteArchiveSpan", + Handler: _ArchiveSpanWriterPlugin_WriteArchiveSpan_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "storage.proto", +} + +// ArchiveSpanReaderPluginClient is the client API for ArchiveSpanReaderPlugin service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ArchiveSpanReaderPluginClient interface { + // spanstore/Reader + GetArchiveTrace(ctx context.Context, in *GetTraceRequest, opts ...grpc.CallOption) (ArchiveSpanReaderPlugin_GetArchiveTraceClient, error) +} + +type archiveSpanReaderPluginClient struct { + cc *grpc.ClientConn +} + +func NewArchiveSpanReaderPluginClient(cc *grpc.ClientConn) ArchiveSpanReaderPluginClient { + return &archiveSpanReaderPluginClient{cc} +} + +func (c *archiveSpanReaderPluginClient) GetArchiveTrace(ctx context.Context, in *GetTraceRequest, opts ...grpc.CallOption) (ArchiveSpanReaderPlugin_GetArchiveTraceClient, error) { + stream, err := c.cc.NewStream(ctx, &_ArchiveSpanReaderPlugin_serviceDesc.Streams[0], "/jaeger.storage.v1.ArchiveSpanReaderPlugin/GetArchiveTrace", opts...) + if err != nil { + return nil, err + } + x := &archiveSpanReaderPluginGetArchiveTraceClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type ArchiveSpanReaderPlugin_GetArchiveTraceClient interface { + Recv() (*SpansResponseChunk, error) + grpc.ClientStream +} + +type archiveSpanReaderPluginGetArchiveTraceClient struct { + grpc.ClientStream +} + +func (x *archiveSpanReaderPluginGetArchiveTraceClient) Recv() (*SpansResponseChunk, error) { + m := new(SpansResponseChunk) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// ArchiveSpanReaderPluginServer is the server API for ArchiveSpanReaderPlugin service. +type ArchiveSpanReaderPluginServer interface { + // spanstore/Reader + GetArchiveTrace(*GetTraceRequest, ArchiveSpanReaderPlugin_GetArchiveTraceServer) error +} + +func RegisterArchiveSpanReaderPluginServer(s *grpc.Server, srv ArchiveSpanReaderPluginServer) { + s.RegisterService(&_ArchiveSpanReaderPlugin_serviceDesc, srv) +} + +func _ArchiveSpanReaderPlugin_GetArchiveTrace_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetTraceRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ArchiveSpanReaderPluginServer).GetArchiveTrace(m, &archiveSpanReaderPluginGetArchiveTraceServer{stream}) +} + +type ArchiveSpanReaderPlugin_GetArchiveTraceServer interface { + Send(*SpansResponseChunk) error + grpc.ServerStream +} + +type archiveSpanReaderPluginGetArchiveTraceServer struct { + grpc.ServerStream +} + +func (x *archiveSpanReaderPluginGetArchiveTraceServer) Send(m *SpansResponseChunk) error { + return x.ServerStream.SendMsg(m) +} + +var _ArchiveSpanReaderPlugin_serviceDesc = grpc.ServiceDesc{ + ServiceName: "jaeger.storage.v1.ArchiveSpanReaderPlugin", + HandlerType: (*ArchiveSpanReaderPluginServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "GetArchiveTrace", + Handler: _ArchiveSpanReaderPlugin_GetArchiveTrace_Handler, + ServerStreams: true, + }, + }, + Metadata: "storage.proto", +} + // DependenciesReaderPluginClient is the client API for DependenciesReaderPlugin service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. @@ -1291,6 +1555,70 @@ var _DependenciesReaderPlugin_serviceDesc = grpc.ServiceDesc{ Metadata: "storage.proto", } +// PluginCapabilitiesClient is the client API for PluginCapabilities service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type PluginCapabilitiesClient interface { + Capabilities(ctx context.Context, in *CapabilitiesRequest, opts ...grpc.CallOption) (*CapabilitiesResponse, error) +} + +type pluginCapabilitiesClient struct { + cc *grpc.ClientConn +} + +func NewPluginCapabilitiesClient(cc *grpc.ClientConn) PluginCapabilitiesClient { + return &pluginCapabilitiesClient{cc} +} + +func (c *pluginCapabilitiesClient) Capabilities(ctx context.Context, in *CapabilitiesRequest, opts ...grpc.CallOption) (*CapabilitiesResponse, error) { + out := new(CapabilitiesResponse) + err := c.cc.Invoke(ctx, "/jaeger.storage.v1.PluginCapabilities/Capabilities", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PluginCapabilitiesServer is the server API for PluginCapabilities service. +type PluginCapabilitiesServer interface { + Capabilities(context.Context, *CapabilitiesRequest) (*CapabilitiesResponse, error) +} + +func RegisterPluginCapabilitiesServer(s *grpc.Server, srv PluginCapabilitiesServer) { + s.RegisterService(&_PluginCapabilities_serviceDesc, srv) +} + +func _PluginCapabilities_Capabilities_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CapabilitiesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PluginCapabilitiesServer).Capabilities(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/jaeger.storage.v1.PluginCapabilities/Capabilities", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PluginCapabilitiesServer).Capabilities(ctx, req.(*CapabilitiesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _PluginCapabilities_serviceDesc = grpc.ServiceDesc{ + ServiceName: "jaeger.storage.v1.PluginCapabilities", + HandlerType: (*PluginCapabilitiesServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Capabilities", + Handler: _PluginCapabilities_Capabilities_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "storage.proto", +} + func (m *GetDependenciesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1828,6 +2156,68 @@ func (m *FindTraceIDsResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *CapabilitiesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CapabilitiesRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *CapabilitiesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CapabilitiesResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.ArchiveSpanReader { + dAtA[i] = 0x8 + i++ + if m.ArchiveSpanReader { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + if m.ArchiveSpanWriter { + dAtA[i] = 0x10 + i++ + if m.ArchiveSpanWriter { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + func encodeVarintStorage(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -2114,6 +2504,36 @@ func (m *FindTraceIDsResponse) Size() (n int) { return n } +func (m *CapabilitiesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *CapabilitiesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ArchiveSpanReader { + n += 2 + } + if m.ArchiveSpanWriter { + n += 2 + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func sovStorage(x uint64) (n int) { for { n++ @@ -3815,6 +4235,154 @@ func (m *FindTraceIDsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *CapabilitiesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CapabilitiesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CapabilitiesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipStorage(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthStorage + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthStorage + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CapabilitiesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CapabilitiesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CapabilitiesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ArchiveSpanReader", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ArchiveSpanReader = bool(v != 0) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ArchiveSpanWriter", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ArchiveSpanWriter = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipStorage(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthStorage + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthStorage + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipStorage(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0