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

Example not using dot notation in plugin.Call to go process #9

Open
hekaldama opened this issue Dec 8, 2015 · 3 comments
Open

Example not using dot notation in plugin.Call to go process #9

hekaldama opened this issue Dec 8, 2015 · 3 comments

Comments

@hekaldama
Copy link

I see in: https://github.com/natefinch/pie/blob/master/examples/python/master.go#L73 that we can pass a JSON-RPC to the plugin without dot notation like "add". Is it possible to do this to a pie provider? I can only get dot style working like the examples of 'Plugin.SayHi'.

My ultimate use case is to have a daemon that listens for docker events, gets some data from the docker daemon, then forwards that data onto plugins specified in a conf file. I would like to be able to call all the defined plugins with just 'start' instead of 'plugin.start' and I need the plugins to be able to be written in any language. Let me know if that doesn't make sense.

@hekaldama
Copy link
Author

Basically I want to implement a main program that is able to call other plugins with a language agnostic JSONRPC method signature. I feel what net/rpc requires us to do with things like 'Plugin.SayHi' is very golang specific. I wonder if we can have a method in pie that will be RegisterNameWithMap and the map is the interface for clients of pie to say 'what_i_will_be_called_with' maps to 'Exposed.Function'

@hekaldama
Copy link
Author

Example of where I am calling 'Api.Start':

https://github.com/yp-engineering/docker-event-hook/blob/master/docker-events-hook.go#L81

but I would rather just call 'start' because my plugins could be written in any language and it doesn't seem like others dictate 'Capital.Capital' type method naming. Like your python example in pie:

https://github.com/natefinch/pie/blob/master/examples/python/plugin.py#L31-L38

and

https://github.com/natefinch/pie/blob/master/examples/python/master.go#L73

@natefinch
Copy link
Owner

Sorry to take so long to get back to you on this. I'm really not a python expert... but I believe the restriction is from the Go RPC library - it expects to be calling methods on types, so it expects the Namespace.Function format. It may seem cumbersome at first, but it actually opens up a lot of nice behaviors down the road. You can separate out different functionality into related chunks, for example. It also makes it easy to make backwards-incompatible changes by just putting the new code in a v2 namespace.

I don't have a huge amount of free time rigI can look into exactly how you might ht now, but I'll see what I can figure out. You might try pinging @lonelycode for more information on working with go's RPC framework from python, since he contributed that example.

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

No branches or pull requests

2 participants