Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added plugins feature that allows separate binaries as processes #58

Open
wants to merge 3 commits into
base: parser
Choose a base branch
from

Conversation

dahvid
Copy link

@dahvid dahvid commented Sep 22, 2020

Used the loader.go which was not compiled, I had to brutalize it a bit, to get it to work with plugins.
Need a conversation about what the intention was of some of the non-working code in it.

dahvid and others added 2 commits September 22, 2020 13:33
Used the loader which was compiled out, and had to brutilize it a bit
Need a conversation about what the intention was of some of the non-working code i it
The first layer of management is that parameters can be passed to the Plugins via
the Json graph, under an optional Parameters field
Copy link
Owner

@trustmaster trustmaster left a comment

Choose a reason for hiding this comment

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

Hello @dahvid ! Thanks for your Pull Request and sorry for a late reply.

If I understood correctly, Plugins are Components that can be compiled separately from the application and loaded at run-time from shared libraries. I think it's a great contribution!

This PR needs further work to be merged to the main repo:

  1. It would be nice to add some explanation in the description of this PR on what "plugins" are, when and how to use them.
  2. Could you base it on master branch rather than parser? parser is WIP and it doesn't seem like these changes really depend on it.
  3. Could you please make sure the tests pass and that test coverage remains at ~90% level?
  4. Please add descriptive godoc strings to all exported types and functions.

See more comments inline.

@@ -89,6 +89,11 @@ func (n *Graph) Add(name string, c interface{}) error {
return nil
}

// Get a component by name
func (n *Graph) Get(name string) interface{} {
Copy link
Owner

Choose a reason for hiding this comment

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

This name is ambiguous. I'd suggest calling it GetProcess() instead.

// Parse JSON into Go struct
var descr graphDescription
err := json.Unmarshal(js, &descr)
if err != nil {
fmt.Println("Error parsing JSON", err)
Copy link
Owner

Choose a reason for hiding this comment

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

Please clean up all debug prints before merging, and make use of error to return errors to caller.

const plugInSuffix = `_goplug.so`

//PlugIn something
type PlugIn interface {
Copy link
Owner

Choose a reason for hiding this comment

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

Are params mandatory for all plugins? Can't we just load any components as plugins? Forcing all plugin components adhere to this interface is quite restrictive.

Also, I have a strong feeling that Parameters is reinventing IIPs. In FBP, IIPs (initial IPs) are used to send pre-defined input to components. See graph_iip_test.go for example.

@@ -0,0 +1,5 @@
#!/bin/bash
Copy link
Owner

Choose a reason for hiding this comment

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

I believe this file should live in test_plugins/.

@dahvid
Copy link
Author

dahvid commented Oct 12, 2020 via email

@trustmaster
Copy link
Owner

trustmaster commented Oct 12, 2020

@dahvid

Re: IIPs vs. map[string]interface{} params

I agree that there are cases for more complex configuration of the components rather than just a plain scalar value. However, I believe that an Initial IP is a concept good enough to cover this problem. For example, as you're primarily dealing with JSON graph definitions, it is quite natural to have IIPs coming as JSON objects.

In the current version of JSON graph definitions, which is compatible with noflo, you could do it this way:

"connections": [
  {
    "data": {
      "someParam": "value",
      "anotherParam": 123
    },
    "tgt": {
      "process": "Reader",
      "port": "config"
    }
  }
]

It is totally fine for a port to be used only once for configuration. It makes it explicit to the graph designer: this component requires configuration. This is exactly what IIPs exist for in FBP, and I would like to stick to the original paradigm unless implementing features that are orthogonal and not really represented in the original concept.

Re: plugins in Golang

Honestly, I didn't even know about Go plugins before this PR. And I see there are problems with them.

Question: do you need plugins to add components at run-time, or to package components separately? Is it a required thing in your use case?

If you don't need run-time evolution of the graphs, nor shipping components as binary packages, then just compiling everything as a single binary shouldn't be a big issue given Go's compiler speed.

Re: managed plugin model

Could you elaborate a bit on what you are aiming to achieve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants