Documentation ¶
Index ¶
- type Client
- type InvokeHandler
- type RPCServerInfo
- type RegHandler
- type Server
- type ServerGroup
- func (group *ServerGroup) GetByUUID(uuid string) (*Client, error)
- func (group *ServerGroup) GoWatchFile()
- func (group *ServerGroup) Init(configFile string) error
- func (group *ServerGroup) InvokeAll(hander InvokeHandler) error
- func (group *ServerGroup) InvokeByUUID(uuid string, hander InvokeHandler) error
- func (group *ServerGroup) InvokeRand(hander InvokeHandler) error
- func (group *ServerGroup) RandOne() (*Client, error)
- func (group *ServerGroup) RegInterceptor(hander grpc.UnaryClientInterceptor)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { RPCInfo *RPCServerInfo // RPC信息 // contains filtered or unexported fields }
Client RPC客户端
func (*Client) RegInterceptor ¶
func (c *Client) RegInterceptor(hander grpc.UnaryClientInterceptor)
RegInterceptor 注册拦截器
type RPCServerInfo ¶
type RPCServerInfo struct { UUID string `json:"uuid"` // RPC服务UUID,用于服务器判别 IP string `json:"ip"` // PRC IP地址 Port int `json:"port"` // RPC端口号 IsOpenTLS bool `json:"isOpenTLS"` // 是否启用TLS认证,如果启用,则必须要指明公钥Key和私钥Pem的文件地址 Key string `json:"key"` // 公钥,供服务端使用 Pem string `json:"pem"` // 私钥 TLSName string `json:"tlsName"` // 加密名,供客户端使用 IsUseSign bool `json:"isUseSign"` // 是否启用MD5签名认证,如果启用,则必须要设置AppID和AppKey AppID string `json:"appId"` // 自定义验证APPID,暂时固定值,以后扩展使用 AppKey string `json:"appKey"` // 自定义验证APPKEY }
RPCServerInfo RPC服务配置实体类
var ( // RPCServerSetting RPC Server Setting RPCServerSetting *RPCServerInfo )
func LoadRPCServerConfig ¶
func LoadRPCServerConfig(cfg *ini.File) *RPCServerInfo
LoadRPCServerConfig 设置RPC服务配置信息
type Server ¶
type Server struct { RPCInfo *RPCServerInfo // RPC信息 GRPCServer *grpc.Server Listener net.Listener }
Server RPC服务对象
func InitServerFromIniConfig ¶
InitServerFromIniConfig 初始化RPC服务器
func (*Server) Register ¶
func (s *Server) Register(regFunc RegHandler)
Register 注册函数对象 @Example:
server.Register(func(grpcServer *grpc.Server) { pb.RegisterHelloServer(grpcServer, &service.HelloService{}) })
type ServerGroup ¶
type ServerGroup struct { InfoList []*RPCServerInfo // RPC信息库列表 ServerList []*Client // RPC Server列表 // contains filtered or unexported fields }
ServerGroup RPC服务器群管理信息
func (*ServerGroup) GetByUUID ¶
func (group *ServerGroup) GetByUUID(uuid string) (*Client, error)
GetByUUID 根据UIID来获取RPC服务器信息
func (*ServerGroup) InvokeAll ¶
func (group *ServerGroup) InvokeAll(hander InvokeHandler) error
InvokeAll RPC集群群体调用
func (*ServerGroup) InvokeByUUID ¶
func (group *ServerGroup) InvokeByUUID(uuid string, hander InvokeHandler) error
InvokeByUUID 调用
func (*ServerGroup) InvokeRand ¶
func (group *ServerGroup) InvokeRand(hander InvokeHandler) error
InvokeRand 随机调用
func (*ServerGroup) RegInterceptor ¶
func (group *ServerGroup) RegInterceptor(hander grpc.UnaryClientInterceptor)
RegInterceptor 全体注册拦截器
Click to show internal directories.
Click to hide internal directories.