27 lines
466 B
Go
27 lines
466 B
Go
package rpcsup
|
|
|
|
import (
|
|
"errors"
|
|
"net"
|
|
"net/rpc"
|
|
"net/rpc/jsonrpc"
|
|
"strings"
|
|
)
|
|
|
|
func RpcClient(conf *RpcConfig) (*rpc.Client, error) {
|
|
if strings.Contains(conf.Typec, "json") {
|
|
dial, err := net.Dial(conf.Network, conf.Address)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return jsonrpc.NewClient(dial), nil
|
|
}
|
|
|
|
if strings.Contains(conf.Typec, "grpc") {
|
|
return nil, errors.New("currently not supported")
|
|
}
|
|
|
|
return rpc.Dial(conf.Network, conf.Address)
|
|
}
|