rpc: remove 'exported or builtin' restriction for parameters (#20332)
* rpc: remove 'exported or builtin' restriction for parameters There is no technial reason for this restriction because package reflect can create values of any type. Requiring parameters and return values to be exported causes a lot of noise in package exports. * rpc: fix staticcheck warnings
This commit is contained in:
committed by
Péter Szilágyi
parent
9c6cf960b4
commit
8008c5b1fa
10
rpc/doc.go
10
rpc/doc.go
@ -29,8 +29,6 @@ Methods that satisfy the following criteria are made available for remote access
|
||||
|
||||
- method must be exported
|
||||
- method returns 0, 1 (response or error) or 2 (response and error) values
|
||||
- method argument(s) must be exported or builtin types
|
||||
- method returned value(s) must be exported or builtin types
|
||||
|
||||
An example method:
|
||||
|
||||
@ -74,13 +72,8 @@ An example server which uses the JSON codec:
|
||||
calculator := new(CalculatorService)
|
||||
server := NewServer()
|
||||
server.RegisterName("calculator", calculator)
|
||||
|
||||
l, _ := net.ListenUnix("unix", &net.UnixAddr{Net: "unix", Name: "/tmp/calculator.sock"})
|
||||
for {
|
||||
c, _ := l.AcceptUnix()
|
||||
codec := v2.NewJSONCodec(c)
|
||||
go server.ServeCodec(codec, 0)
|
||||
}
|
||||
server.ServeListener(l)
|
||||
|
||||
Subscriptions
|
||||
|
||||
@ -90,7 +83,6 @@ criteria:
|
||||
|
||||
- method must be exported
|
||||
- first method argument type must be context.Context
|
||||
- method argument(s) must be exported or builtin types
|
||||
- method must have return types (rpc.Subscription, error)
|
||||
|
||||
An example method:
|
||||
|
Reference in New Issue
Block a user