Open hekaldama opened 8 years ago
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'
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
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.
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.