-
Notifications
You must be signed in to change notification settings - Fork 88
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
Service registration like in net/rpc #87
Comments
This is an excellent idea. I've wanted to do the same thing, but haven't had the time yet. It looks like the net/rpc client implementation would be a great starting place. I've added you as a collaborator. If you want to work on this, you can use the dev branch until it's ready to merge into v2. |
I got a prototype wrapper around the current client.Register/Call function working. It needs a lot more work and testing. I will push to the dev branch once I moved the code to turnpike and wrote a test suite. I could reduce a lot of argument/type checking in my code. It definitely helps. |
I need to add a dependency https://github.com/mitchellh/mapstructure or write my own map[string]interface{} to decoder. What would you prefer? |
I hadn't seen that library before--I could have used it a few times in the past. It looks fairly well-tested, so I wouldn't mind depending on it. I would like to look into vendoring dependencies at some point in the future. But the Go 1.5 vendor feature is only experimental and you have to manually enable it with an environment variable. Also, |
I got it working with a test-suit and without the mapstructure dependency. I don't know how well it will work with a none Go caller. I need to test it with my JavaScript code. |
…s Services to be registered similar to net/rpc package. Add exported functions Client.RegisterService, Client.RegisterServiceName Client.UnregisterService and Client.CallService.
The tests work because no serialization happens between the two test clients. |
I would like to do something similar to Publish and Subscribe. Add a method to Client: func (c *Client) Broadcast(topic string, arguments ...interface{}) error And extend Client.RegisterService to use methods which start with "On" as event listeners for publish messages, instead of a registration as a procedure. Or add a separate method to subscribe to topics with a service, like: func (c *Client) Listen(service interface{}) error Which uses all exported methods like RegisterService does and instead of registering it as a procedure, it subscribes to a topic. What do you prefer? Any thoughts? |
I implemented the first idea, minus the Client.Broadcast function. It would just be a one line short form of Client.Publish. @jcelliott could you check the code, please. I would like to merge it into v2 and start on the 33 data races, which are currently in v2. In dev there are only two. |
I like the idea of a "service" interface for events. I was also thinking it would be nice to use the reflection code you added for a regular registration as well. Then maybe the current I will take a look at it this evening and hopefully merge the dev branch in. |
If we merge Client.Register and Client.RegisterService, I wouldn't export the current Client.Register after the merge as Client.RegisterRaw. We would have the same amount of exported methods but one does more complicated stuff. We could also merge Client.Subscribe which has the same WAMP arguments as register. The problem I see is that we no longer follow the "naming convention" of the WAMP spec. |
I was thinking we would keep |
…s Services to be registered similar to net/rpc package. Add exported functions Client.RegisterService, Client.RegisterServiceName Client.UnregisterService and Client.CallService.
The service methods are being registered as "Type.Method" at the moment. In the WAMP spec the example names for procedures have "type.method" all lowercase naming. Do you think I should change it to all lowercase? |
I got an idea on how to do integrate event publishing into the service feature. type Service struct {
PublishX func(arg1 string) error
} Client.RegisterService would set PublishX and calls to PublishX would send an PUBLISH wamp event to topic Service.OnX. |
I would like to implement something similar to the net/rpc package service registration. It would remove the reflection/type checking in the user code and would allow for WAMP reflection later.
For example:
The text was updated successfully, but these errors were encountered: