Declare option not options
This commit is contained in:
parent
9d514f0e60
commit
4f909d0be4
@ -16,12 +16,18 @@ type options struct {
|
||||
transport transport.Transport
|
||||
}
|
||||
|
||||
type Options func(*options)
|
||||
type Option func(*options)
|
||||
|
||||
var (
|
||||
DefaultClient Client = NewRpcClient()
|
||||
)
|
||||
|
||||
func Transport(t transport.Transport) Option {
|
||||
return func(o *options) {
|
||||
o.transport = t
|
||||
}
|
||||
}
|
||||
|
||||
func Call(request Request, response interface{}) error {
|
||||
return DefaultClient.Call(request, response)
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ func (r *RpcClient) NewJsonRequest(service, method string, request interface{})
|
||||
return newRpcRequest(service, method, request, "application/json")
|
||||
}
|
||||
|
||||
func NewRpcClient(opt ...Options) *RpcClient {
|
||||
func NewRpcClient(opt ...Option) *RpcClient {
|
||||
var opts options
|
||||
|
||||
for _, o := range opt {
|
||||
|
@ -123,7 +123,7 @@ func (s *RpcServer) Stop() error {
|
||||
return <-ch
|
||||
}
|
||||
|
||||
func NewRpcServer(address string, opt ...Options) *RpcServer {
|
||||
func NewRpcServer(address string, opt ...Option) *RpcServer {
|
||||
var opts options
|
||||
|
||||
for _, o := range opt {
|
||||
|
@ -27,7 +27,7 @@ type options struct {
|
||||
transport transport.Transport
|
||||
}
|
||||
|
||||
type Options func(*options)
|
||||
type Option func(*options)
|
||||
|
||||
var (
|
||||
Address string
|
||||
@ -36,6 +36,12 @@ var (
|
||||
DefaultServer Server
|
||||
)
|
||||
|
||||
func Transport(t transport.Transport) Option {
|
||||
return func(o *options) {
|
||||
o.transport = t
|
||||
}
|
||||
}
|
||||
|
||||
func Init() error {
|
||||
defer log.Flush()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user