Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Client libs to enable non-go language plugins #1150

Merged
merged 8 commits into from
Aug 25, 2016

Conversation

IRCody
Copy link
Contributor

@IRCody IRCody commented Aug 17, 2016

Partially addresses #965
Via some changes re: content-types, resolves #771.

Summary of changes:
These changes are geared around enabling non-go plugins to be written by using grpc. It moves some of the go specific code to the clients (where we differentiate between the native/go client and grpc client) so that native clients and grpc clients can co-exist in the same workflow (and outside of the clients, they follow the same code path through snapd).

For a more specific summary see the commit messages.

Things to note:

  • All existing plugins should continue to work and can be used in conjunction with grpc plugins with no special action from the user.
  • The concept of content-types is removed. Content-types were never functional and would require decently significant breaking changes to the plugin API to support. Removing them simplifies the representation of metrics inside snapd.

Things not included in this PR:

  • Security features can be integrated into gRPC but are not included inside these changes.
  • gRPC plugin libs -- Since we are going to have multiple plugin libs that live in there own repos, these changes don't include any of those changes. There is a c++ currently being worked on with plans for more in the future. The goal is that writing a plugin-lib for any language that supports gRPC should be relatively straight forward utilizing the same proto definitions to generate the service interface that snap requires.

Testing done:

  • make test-{small, medium, legacy}
  • Manual testing with existing plugins and some prototype plugins that utilize grpc.

@intelsdi-x/snap-maintainers

IRCody added 6 commits August 17, 2016 11:12
Updates control package to use metrics throughout the workflow. This new
function prototype had to be changed in a few places.

Removes josnrc process/publish client creation since it is only able to
be used for collection.

Adds invalid rpctype error if unable to match the incoming rpctype.
Updates plugin package. Removes grpc server actions from the package
since this is being moved to a new plugin-lib repo.

Updates client package to use new function prototypes of passing metric
all the way through a workflow instead of bytes through process/publish.

For native/gob, the encoding/decoding now happens in the client. This is
done because the concept of contentType was removed form the framework
but we still want to support existing plugins. Doing this in the client
allows existing plugins to interact with plugins written using any other
langauge lib.

Updates proto definitions, including adding some types that were
previously referenced from common. This was done to allow plugin-libs
written in other languages to only require one proto file to generate
from, reducing complexity for the plugin-lib authors at the cost of some
duplication.
In cpolicy, when Merge is called it modifies the callers rules which is
not the desired behavior. This adds the creation of a new node that is
used to contain the merged rules.
Updates controlproxy to match new managesMetrics interface. Updates
tests and proto files to match.
Updates scheduler managesMetrics interface to use core.Metric all the
way through a workflow instead of switching to bytes for process and
publish. This removes the un-implemented contentType feature and
associated testing/partial implementations.
type collectsMetrics interface {
CollectMetrics(string, map[string]map[string]string) ([]core.Metric, []error)
}

type publishesMetrics interface {
PublishMetrics(contentType string, content []byte, pluginName string, pluginVersion int, config map[string]ctypes.ConfigValue, taskID string) []error
PublishMetrics([]core.Metric, map[string]ctypes.ConfigValue, string, string, int) []error
//PublishMetrics(contentType string, content []byte, pluginName string, pluginVersion int, config map[string]ctypes.ConfigValue, taskID string) []error
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the comment here?

@mbbroberg
Copy link
Contributor

When this lands, we can bring #660 back up 👌

br, err = cpolicy.NewBoolRule(key, val.Required, val.Default)
} else {
br, err = cpolicy.NewBoolRule(key, val.Required)
}
if err != nil {
// The only error that can be thrown is empty key error, ignore something with empty key
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we call the plugin's GetConfigPolicy and receive a ConfigPolicyNode which contains an empty key we might want to log this (level=warning). What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added warning statement here. I don't have a strong opinion on it.

@jcooklin
Copy link
Collaborator

LGTM

@pittma
Copy link
Contributor

pittma commented Aug 25, 2016

LGTM

@IRCody IRCody merged commit 67417ef into intelsdi-x:master Aug 25, 2016
@IRCody IRCody deleted the client-libs branch October 11, 2016 17:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SnapGOBContentType only type supported for Processor and Publisher plugins
4 participants