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

proposal: support custom method names in net/rpc #16449

Closed
tdterry opened this issue Jul 20, 2016 · 2 comments
Closed

proposal: support custom method names in net/rpc #16449

tdterry opened this issue Jul 20, 2016 · 2 comments

Comments

@tdterry
Copy link

tdterry commented Jul 20, 2016

I'm converting a legacy system that uses json-rpc into Go, and I have some restrictions on the method names that don't work with Go's RPC layer. The legacy method names are all lowercase and do not have a namespace structure "method_name". Go's RPC layer wants to use "Class.Method" as the method name. It would be very useful to be able to either a) provide a mapping of method names when registering a handler or b) register individual methods with a custom name.

Something like this, as taken from the net/rpc package example:

arith := new(Arith)
rpc.RegisterWithNames(arith, map[string]string{
    "mul": "Arith.Multiply",
    "div": "Arith.Divide",
})

// or

rpc.RegisterMethod("mul", Arith.Multiply)
rpc.RegisterMethod("div", Arith.Divide)
@mem
Copy link

mem commented Jul 20, 2016

I actually keep a small fork of net/rpc for this very reason, and it's not a legacy system, it's something designed in the last couple of years. Some people simply have different tasted when designing APIs :-P

@robpike
Copy link
Contributor

robpike commented Sep 12, 2016

#16844 proposes freezing this package, which I think will be accepted, so I would prefer that @mem just maintains his fork.

@adg adg closed this as completed Oct 24, 2016
@golang golang locked and limited conversation to collaborators Oct 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants