Documentation
¶
Index ¶
Constants ¶
View Source
const ( TCP = netx.TcpNetwork TCP4 = netx.Tcp4Network TCP6 = netx.Tcp6Network UDP = netx.UDPNetwork )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IRPCClient ¶
type IRPCClient interface {
// Dial
// 连接远程RPC服务
Dial(address string) error
// IsConnected
// RPC是否处理连接状态
IsConnected() bool
// Call
// 调用RPC服务
// args: 远程RPC服务方法参数
// reply: 远程RPC服务方法返回值, 必须为指针引用
// 返回值: 错误信息
// 错误信息: nil: 成功; 非nil: 失败
Call(serviceMethod string, args interface{}, reply interface{}) error
// Close
// 关闭远程RPC服务
Close()
}
func NewRPCClient ¶
func NewRPCClient() IRPCClient
func NewRPCClientWithNetwork ¶
func NewRPCClientWithNetwork(network string) IRPCClient
type IRPCServer ¶
type IRPCServer interface {
// Register
// publishes in the server the set of methods of the receiver value that satisfy the following conditions:
// 参数格式:
// rcvr: new(Arith), Arith为结构体
Register(rcvr interface{}) error
// RegisterName
// is like Register but uses the provided name for the type instead of the receiver's concrete type.
// 参数格式:
// rcvr: new(Arith), Arith为结构体
RegisterName(name string, rcvr interface{}) error
// StartServer
// 启动RPC服务,会阻塞
StartServer(addr string)
// StopServer
// 停止RPC服务
StopServer()
}
func NewRPCServer ¶
func NewRPCServer() IRPCServer
func NewRPCServerWithNetwork ¶
func NewRPCServerWithNetwork(network string) IRPCServer
type RPCClient ¶
type RPCClient struct {
Network string
// contains filtered or unexported fields
}
func (*RPCClient) IsConnected ¶
type RPCServer ¶
type RPCServer struct {
logx.LoggerSupport
Network string
Server *rpc.Server
Listener net.Listener
}
func (*RPCServer) RegisterName ¶
func (*RPCServer) StartServer ¶
func (*RPCServer) StopServer ¶
func (s *RPCServer) StopServer()
Click to show internal directories.
Click to hide internal directories.