-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gRPC Plugin framework #1461
Merged
Merged
gRPC Plugin framework #1461
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
2d32099
Add New Storage Plugin Framework
olivierboucher 1a21e65
Remove old generated storage file
chvck 70f43dc
Update plugin grpc interface/implementation
chvck 482edd6
Fix gosec by adding an exclude comment
chvck be72ed7
Run make fmt
chvck 9925b38
Remove unused plugin file
chvck 74aaf5e
Add comments to uncommented functions
chvck a8a0114
Split grpc server and client into separate files
chvck ef0078f
Use errors.wrap rather than fmt for errors
chvck 931dfa4
Add copyright header to grpc server file
chvck d5fe102
Update headers to updated license on uncommitted files
chvck f56cc80
Merge branch 'master' into chvck/plugin-framework
chvck 7dc2b9a
Merge branch 'master' into chvck/plugin-framework
chvck f180890
Move grpc config to plugin/storage
chvck 419f4ce
Add empty test files to fix build
9f482b4
Merge branch 'master' into chvck/plugin-framework
chvck 3919ac6
Move grpc config empty_test file
chvck 5e87836
Merge branch 'master' into plugin-framework
7e7b072
Merge pull request #2 from yurishkuro/plugin-framework-fix-gosec
chvck 7ffb8b6
Change fmt for error to errors.Wrap
chvck c136b37
Use single-line for comprehensions where possible
chvck 978eb07
Don't accumulate spans before sending
chvck 0abb726
Add function to serve the plugin
chvck dd199ad
Merge branch 'master' into chvck/plugin-framework
chvck 79e0849
Small grpc client refactor
chvck b747fb9
Update grpc interface and move noop plugin to examples
chvck 03db22b
Add missed fix for factory
chvck ba8b35f
Rename memory-store example to memstore-plugin
chvck 616f1b9
Refactor Serve to call ServeWithGRPCServer
chvck bf0e140
Refactor to make some structs private
chvck deba568
Change factory_test to use mocks
chvck 763ec4c
Add storage grpc integration test
chvck 3b5e9ea
Create mocks for storage_v1 and add grpc client tests
chvck 6041195
Add grpc server tests
chvck 86d8a1f
Run make fmt
chvck 84a7a67
Merge branch 'master' into chvck/plugin-framework
chvck 4a43047
Strip unnecessary code from test
chvck 83f7edc
Merge branch 'master' into plugin-framework
yurishkuro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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 main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// 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 main | ||
|
||
import ( | ||
"flag" | ||
"path" | ||
"strings" | ||
|
||
"github.com/spf13/viper" | ||
|
||
"github.com/jaegertracing/jaeger/plugin/storage/grpc" | ||
"github.com/jaegertracing/jaeger/storage/dependencystore" | ||
"github.com/jaegertracing/jaeger/plugin/storage/memory" | ||
"github.com/jaegertracing/jaeger/storage/spanstore" | ||
) | ||
|
||
var configPath string | ||
|
||
func main() { | ||
flag.StringVar(&configPath, "config", "", "A path to the plugin's configuration file") | ||
flag.Parse() | ||
|
||
if configPath != "" { | ||
viper.SetConfigFile(path.Base(configPath)) | ||
viper.AddConfigPath(path.Dir(configPath)) | ||
} | ||
|
||
v := viper.New() | ||
v.AutomaticEnv() | ||
v.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_")) | ||
|
||
opts := memory.Options{} | ||
opts.InitFromViper(v) | ||
|
||
grpc.Serve(&memoryStore{store: memory.NewStore()}) | ||
} | ||
|
||
type memoryStore struct { | ||
store *memory.Store | ||
} | ||
|
||
func (ns *memoryStore) DependencyReader() dependencystore.Reader { | ||
return ns.store | ||
} | ||
|
||
func (ns *memoryStore) SpanReader() spanstore.Reader { | ||
return ns.store | ||
} | ||
|
||
func (ns *memoryStore) SpanWriter() spanstore.Writer { | ||
return ns.store | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) 2019 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 | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"runtime" | ||
|
||
"github.com/hashicorp/go-hclog" | ||
"github.com/hashicorp/go-plugin" | ||
|
||
"github.com/jaegertracing/jaeger/plugin/storage/grpc/shared" | ||
) | ||
|
||
// Configuration describes the options to customize the storage behavior | ||
type Configuration struct { | ||
PluginBinary string `yaml:"binary"` | ||
PluginConfigurationFile string `yaml:"configuration-file"` | ||
} | ||
|
||
// Build instantiates a StoragePlugin | ||
func (c *Configuration) Build() (shared.StoragePlugin, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file comes up with large gap in coverage, but we can actually test it using |
||
// #nosec G204 | ||
cmd := exec.Command(c.PluginBinary, "--config", c.PluginConfigurationFile) | ||
|
||
client := plugin.NewClient(&plugin.ClientConfig{ | ||
HandshakeConfig: shared.Handshake, | ||
VersionedPlugins: map[int]plugin.PluginSet{ | ||
1: shared.PluginMap, | ||
}, | ||
Cmd: cmd, | ||
AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC}, | ||
Logger: hclog.New(&hclog.LoggerOptions{ | ||
Level: hclog.Warn, | ||
}), | ||
}) | ||
|
||
runtime.SetFinalizer(client, func(c *plugin.Client) { | ||
c.Kill() | ||
}) | ||
|
||
rpcClient, err := client.Client() | ||
if err != nil { | ||
return nil, fmt.Errorf("error attempting to connect to plugin rpc client: %s", err) | ||
} | ||
|
||
raw, err := rpcClient.Dispense(shared.StoragePluginIdentifier) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to retrieve storage plugin instance: %s", err) | ||
} | ||
|
||
storagePlugin, ok := raw.(shared.StoragePlugin) | ||
if !ok { | ||
return nil, fmt.Errorf("unexpected type for plugin \"%s\"", shared.StoragePluginIdentifier) | ||
} | ||
|
||
return storagePlugin, nil | ||
} | ||
|
||
// PluginBuilder is used to create storage plugins | ||
type PluginBuilder interface { | ||
Build() (shared.StoragePlugin, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file should be removed (packages with main() are excluded from coverage automatically)