rpcx

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2025 License: MIT Imports: 5 Imported by: 0

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) Call

func (c *RPCClient) Call(serviceMethod string, args interface{}, reply interface{}) error

func (*RPCClient) Close

func (c *RPCClient) Close()

func (*RPCClient) Dial

func (c *RPCClient) Dial(address string) error

func (*RPCClient) IsConnected

func (c *RPCClient) IsConnected() bool

type RPCServer

type RPCServer struct {
	logx.LoggerSupport

	Network  string
	Server   *rpc.Server
	Listener net.Listener
}

func (*RPCServer) Register

func (s *RPCServer) Register(rcvr interface{}) error

func (*RPCServer) RegisterName

func (s *RPCServer) RegisterName(name string, rcvr interface{}) error

func (*RPCServer) StartServer

func (s *RPCServer) StartServer(addr string)

func (*RPCServer) StopServer

func (s *RPCServer) StopServer()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL