Documentation ¶
Index ¶
- Variables
- func RegisterClusterServiceServer(s *grpc.Server, srv ClusterServiceServer)
- func RegisterMasterServiceServer(s *grpc.Server, srv MasterServiceServer)
- type ClusterServiceClient
- type ClusterServiceServer
- type KickMessage
- type LocalMessage
- func (*LocalMessage) Descriptor() ([]byte, []int)deprecated
- func (x *LocalMessage) GetData() []byte
- func (x *LocalMessage) GetFrontendId() string
- func (x *LocalMessage) GetIsError() bool
- func (x *LocalMessage) GetMsgId() int32
- func (x *LocalMessage) GetMsgType() int32
- func (x *LocalMessage) GetRoute() string
- func (x *LocalMessage) GetSid() int64
- func (x *LocalMessage) GetUid() int64
- func (*LocalMessage) ProtoMessage()
- func (x *LocalMessage) ProtoReflect() protoreflect.Message
- func (x *LocalMessage) Reset()
- func (x *LocalMessage) String() string
- type MasterServiceClient
- type MasterServiceServer
- type Member
- func (*Member) Descriptor() ([]byte, []int)deprecated
- func (x *Member) GetAddress() string
- func (x *Member) GetNodeId() string
- func (x *Member) GetNodeType() string
- func (x *Member) GetSettings() map[string]string
- func (*Member) ProtoMessage()
- func (x *Member) ProtoReflect() protoreflect.Message
- func (x *Member) Reset()
- func (x *Member) String() string
- type MemberList
- type PushMessage
- func (*PushMessage) Descriptor() ([]byte, []int)deprecated
- func (x *PushMessage) GetData() []byte
- func (x *PushMessage) GetRoute() string
- func (x *PushMessage) GetUid() int64
- func (*PushMessage) ProtoMessage()
- func (x *PushMessage) ProtoReflect() protoreflect.Message
- func (x *PushMessage) Reset()
- func (x *PushMessage) String() string
- type RemoteMessage
- func (*RemoteMessage) Descriptor() ([]byte, []int)deprecated
- func (x *RemoteMessage) GetData() []byte
- func (x *RemoteMessage) GetNodeId() string
- func (x *RemoteMessage) GetRoute() string
- func (*RemoteMessage) ProtoMessage()
- func (x *RemoteMessage) ProtoReflect() protoreflect.Message
- func (x *RemoteMessage) Reset()
- func (x *RemoteMessage) String() string
- type Response
- type Session
- func (*Session) Descriptor() ([]byte, []int)deprecated
- func (x *Session) GetData() map[string]string
- func (x *Session) GetSid() int64
- func (x *Session) GetUid() int64
- func (*Session) ProtoMessage()
- func (x *Session) ProtoReflect() protoreflect.Message
- func (x *Session) Reset()
- func (x *Session) String() string
- type UnimplementedClusterServiceServer
- func (*UnimplementedClusterServiceServer) CloseSession(context.Context, *Session) (*Response, error)
- func (*UnimplementedClusterServiceServer) KickUser(context.Context, *KickMessage) (*Response, error)
- func (*UnimplementedClusterServiceServer) LocalHandle(context.Context, *LocalMessage) (*Response, error)
- func (*UnimplementedClusterServiceServer) PushToUser(context.Context, *PushMessage) (*Response, error)
- func (*UnimplementedClusterServiceServer) RemoteHandle(context.Context, *RemoteMessage) (*Response, error)
- type UnimplementedMasterServiceServer
- func (*UnimplementedMasterServiceServer) Add(context.Context, *Member) (*Response, error)
- func (*UnimplementedMasterServiceServer) Delete(context.Context, *Member) (*Response, error)
- func (*UnimplementedMasterServiceServer) Register(context.Context, *Member) (*MemberList, error)
- func (*UnimplementedMasterServiceServer) Unregister(context.Context, *Member) (*Response, error)
Constants ¶
This section is empty.
Variables ¶
var File_cluster_proto protoreflect.FileDescriptor
Functions ¶
func RegisterClusterServiceServer ¶
func RegisterClusterServiceServer(s *grpc.Server, srv ClusterServiceServer)
func RegisterMasterServiceServer ¶
func RegisterMasterServiceServer(s *grpc.Server, srv MasterServiceServer)
Types ¶
type ClusterServiceClient ¶
type ClusterServiceClient interface { // 推送消息到用户客户端 // 适用于内部节点调用,网关节点接收消息后,找到对应的session进行push操作 PushToUser(ctx context.Context, in *PushMessage, opts ...grpc.CallOption) (*Response, error) // 踢用户下线 // 适用于内部节点调用,网关节点接收消息后,找到对应的session进行kick操作 KickUser(ctx context.Context, in *KickMessage, opts ...grpc.CallOption) (*Response, error) // 本地消息转发 // 适用于网关节点,接收用户的消息转发给内部节点 LocalHandle(ctx context.Context, in *LocalMessage, opts ...grpc.CallOption) (*Response, error) // 远程消息转发 // 适用于集群后的所有节点,手工调用进行消息通信 RemoteHandle(ctx context.Context, in *RemoteMessage, opts ...grpc.CallOption) (*Response, error) // 关闭session通知 // 接收session关闭的动作,对当前节点进行相关的逻辑处理 CloseSession(ctx context.Context, in *Session, opts ...grpc.CallOption) (*Response, error) }
ClusterServiceClient is the client API for ClusterService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewClusterServiceClient ¶
func NewClusterServiceClient(cc grpc.ClientConnInterface) ClusterServiceClient
type ClusterServiceServer ¶
type ClusterServiceServer interface { // 推送消息到用户客户端 // 适用于内部节点调用,网关节点接收消息后,找到对应的session进行push操作 PushToUser(context.Context, *PushMessage) (*Response, error) // 踢用户下线 // 适用于内部节点调用,网关节点接收消息后,找到对应的session进行kick操作 KickUser(context.Context, *KickMessage) (*Response, error) // 本地消息转发 // 适用于网关节点,接收用户的消息转发给内部节点 LocalHandle(context.Context, *LocalMessage) (*Response, error) // 远程消息转发 // 适用于集群后的所有节点,手工调用进行消息通信 RemoteHandle(context.Context, *RemoteMessage) (*Response, error) // 关闭session通知 // 接收session关闭的动作,对当前节点进行相关的逻辑处理 CloseSession(context.Context, *Session) (*Response, error) }
ClusterServiceServer is the server API for ClusterService service.
type KickMessage ¶
type KickMessage struct { Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"` // 踢下线的uid Reason []byte `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"` // 原因自定义数据 // contains filtered or unexported fields }
func (*KickMessage) Descriptor
deprecated
func (*KickMessage) Descriptor() ([]byte, []int)
Deprecated: Use KickMessage.ProtoReflect.Descriptor instead.
func (*KickMessage) GetReason ¶
func (x *KickMessage) GetReason() []byte
func (*KickMessage) GetUid ¶
func (x *KickMessage) GetUid() int64
func (*KickMessage) ProtoMessage ¶
func (*KickMessage) ProtoMessage()
func (*KickMessage) ProtoReflect ¶
func (x *KickMessage) ProtoReflect() protoreflect.Message
func (*KickMessage) Reset ¶
func (x *KickMessage) Reset()
func (*KickMessage) String ¶
func (x *KickMessage) String() string
type LocalMessage ¶
type LocalMessage struct { Sid int64 `protobuf:"varint,3,opt,name=sid,proto3" json:"sid,omitempty"` // session id Uid int64 `protobuf:"varint,4,opt,name=uid,proto3" json:"uid,omitempty"` // session uid FrontendId string `protobuf:"bytes,2,opt,name=frontendId,proto3" json:"frontendId,omitempty"` // 前端节点id MsgType int32 `protobuf:"varint,1,opt,name=msgType,proto3" json:"msgType,omitempty"` // 消息类型(request,notify,response,push) MsgId int32 `protobuf:"varint,5,opt,name=msgId,proto3" json:"msgId,omitempty"` // 消息序号id Route string `protobuf:"bytes,6,opt,name=route,proto3" json:"route,omitempty"` // 路由 IsError bool `protobuf:"varint,7,opt,name=isError,proto3" json:"isError,omitempty"` // 是否返回错误 Data []byte `protobuf:"bytes,8,opt,name=data,proto3" json:"data,omitempty"` // 自定义数据 // contains filtered or unexported fields }
本地消息结构 (适用于网关消息转发到当前节点执行localHandle的逻辑,也可手工构造调用)
func (*LocalMessage) Descriptor
deprecated
func (*LocalMessage) Descriptor() ([]byte, []int)
Deprecated: Use LocalMessage.ProtoReflect.Descriptor instead.
func (*LocalMessage) GetData ¶
func (x *LocalMessage) GetData() []byte
func (*LocalMessage) GetFrontendId ¶
func (x *LocalMessage) GetFrontendId() string
func (*LocalMessage) GetIsError ¶
func (x *LocalMessage) GetIsError() bool
func (*LocalMessage) GetMsgId ¶
func (x *LocalMessage) GetMsgId() int32
func (*LocalMessage) GetMsgType ¶
func (x *LocalMessage) GetMsgType() int32
func (*LocalMessage) GetRoute ¶
func (x *LocalMessage) GetRoute() string
func (*LocalMessage) GetSid ¶
func (x *LocalMessage) GetSid() int64
func (*LocalMessage) GetUid ¶
func (x *LocalMessage) GetUid() int64
func (*LocalMessage) ProtoMessage ¶
func (*LocalMessage) ProtoMessage()
func (*LocalMessage) ProtoReflect ¶
func (x *LocalMessage) ProtoReflect() protoreflect.Message
func (*LocalMessage) Reset ¶
func (x *LocalMessage) Reset()
func (*LocalMessage) String ¶
func (x *LocalMessage) String() string
type MasterServiceClient ¶
type MasterServiceClient interface { // 请求master服务节点,注册成员 Register(ctx context.Context, in *Member, opts ...grpc.CallOption) (*MemberList, error) // 请求master服务节点,注销成员 Unregister(ctx context.Context, in *Member, opts ...grpc.CallOption) (*Response, error) // 接收新成员通知 Add(ctx context.Context, in *Member, opts ...grpc.CallOption) (*Response, error) // 接收删除成员通知 Delete(ctx context.Context, in *Member, opts ...grpc.CallOption) (*Response, error) }
MasterServiceClient is the client API for MasterService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewMasterServiceClient ¶
func NewMasterServiceClient(cc grpc.ClientConnInterface) MasterServiceClient
type MasterServiceServer ¶
type MasterServiceServer interface { // 请求master服务节点,注册成员 Register(context.Context, *Member) (*MemberList, error) // 请求master服务节点,注销成员 Unregister(context.Context, *Member) (*Response, error) // 接收新成员通知 Add(context.Context, *Member) (*Response, error) // 接收删除成员通知 Delete(context.Context, *Member) (*Response, error) }
MasterServiceServer is the server API for MasterService service.
type Member ¶
type Member struct { NodeId string `protobuf:"bytes,2,opt,name=nodeId,proto3" json:"nodeId,omitempty"` // 节点id NodeType string `protobuf:"bytes,3,opt,name=nodeType,proto3" json:"nodeType,omitempty"` // 节点类型 Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"` // rpc连接地址 Settings map[string]string `` // 节点配置参数 /* 157-byte string literal not displayed */ // contains filtered or unexported fields }
成员结构
func (*Member) Descriptor
deprecated
func (*Member) GetAddress ¶
func (*Member) GetNodeType ¶
func (*Member) GetSettings ¶
func (*Member) ProtoMessage ¶
func (*Member) ProtoMessage()
func (*Member) ProtoReflect ¶
func (x *Member) ProtoReflect() protoreflect.Message
type MemberList ¶
type MemberList struct { List []*Member `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` // contains filtered or unexported fields }
成员列表结构
func (*MemberList) Descriptor
deprecated
func (*MemberList) Descriptor() ([]byte, []int)
Deprecated: Use MemberList.ProtoReflect.Descriptor instead.
func (*MemberList) GetList ¶
func (x *MemberList) GetList() []*Member
func (*MemberList) ProtoMessage ¶
func (*MemberList) ProtoMessage()
func (*MemberList) ProtoReflect ¶
func (x *MemberList) ProtoReflect() protoreflect.Message
func (*MemberList) Reset ¶
func (x *MemberList) Reset()
func (*MemberList) String ¶
func (x *MemberList) String() string
type PushMessage ¶
type PushMessage struct { Route string `protobuf:"bytes,1,opt,name=route,proto3" json:"route,omitempty"` // 路由 Uid int64 `protobuf:"varint,2,opt,name=uid,proto3" json:"uid,omitempty"` // session uid Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // 自定义数据 // contains filtered or unexported fields }
推送消息结构(推送到网关转发到用户客户端)
func (*PushMessage) Descriptor
deprecated
func (*PushMessage) Descriptor() ([]byte, []int)
Deprecated: Use PushMessage.ProtoReflect.Descriptor instead.
func (*PushMessage) GetData ¶
func (x *PushMessage) GetData() []byte
func (*PushMessage) GetRoute ¶
func (x *PushMessage) GetRoute() string
func (*PushMessage) GetUid ¶
func (x *PushMessage) GetUid() int64
func (*PushMessage) ProtoMessage ¶
func (*PushMessage) ProtoMessage()
func (*PushMessage) ProtoReflect ¶
func (x *PushMessage) ProtoReflect() protoreflect.Message
func (*PushMessage) Reset ¶
func (x *PushMessage) Reset()
func (*PushMessage) String ¶
func (x *PushMessage) String() string
type RemoteMessage ¶
type RemoteMessage struct { NodeId string `protobuf:"bytes,3,opt,name=nodeId,proto3" json:"nodeId,omitempty"` // 发送消息的节点id Route string `protobuf:"bytes,6,opt,name=route,proto3" json:"route,omitempty"` // 路由 Data []byte `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"` // 自定义数据 // contains filtered or unexported fields }
远程消息结构(用于开发中手动构造调用)
func (*RemoteMessage) Descriptor
deprecated
func (*RemoteMessage) Descriptor() ([]byte, []int)
Deprecated: Use RemoteMessage.ProtoReflect.Descriptor instead.
func (*RemoteMessage) GetData ¶
func (x *RemoteMessage) GetData() []byte
func (*RemoteMessage) GetNodeId ¶
func (x *RemoteMessage) GetNodeId() string
func (*RemoteMessage) GetRoute ¶
func (x *RemoteMessage) GetRoute() string
func (*RemoteMessage) ProtoMessage ¶
func (*RemoteMessage) ProtoMessage()
func (*RemoteMessage) ProtoReflect ¶
func (x *RemoteMessage) ProtoReflect() protoreflect.Message
func (*RemoteMessage) Reset ¶
func (x *RemoteMessage) Reset()
func (*RemoteMessage) String ¶
func (x *RemoteMessage) String() string
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
响应结构
func (*Response) Descriptor
deprecated
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) ProtoReflect ¶
func (x *Response) ProtoReflect() protoreflect.Message
type Session ¶
type Session struct { Sid int64 `protobuf:"varint,1,opt,name=sid,proto3" json:"sid,omitempty"` Uid int64 `protobuf:"varint,2,opt,name=uid,proto3" json:"uid,omitempty"` Data map[string]string `` /* 149-byte string literal not displayed */ // contains filtered or unexported fields }
Session
func (*Session) Descriptor
deprecated
func (*Session) ProtoMessage ¶
func (*Session) ProtoMessage()
func (*Session) ProtoReflect ¶
func (x *Session) ProtoReflect() protoreflect.Message
type UnimplementedClusterServiceServer ¶
type UnimplementedClusterServiceServer struct { }
UnimplementedClusterServiceServer can be embedded to have forward compatible implementations.
func (*UnimplementedClusterServiceServer) CloseSession ¶
func (*UnimplementedClusterServiceServer) KickUser ¶
func (*UnimplementedClusterServiceServer) KickUser(context.Context, *KickMessage) (*Response, error)
func (*UnimplementedClusterServiceServer) LocalHandle ¶
func (*UnimplementedClusterServiceServer) LocalHandle(context.Context, *LocalMessage) (*Response, error)
func (*UnimplementedClusterServiceServer) PushToUser ¶
func (*UnimplementedClusterServiceServer) PushToUser(context.Context, *PushMessage) (*Response, error)
func (*UnimplementedClusterServiceServer) RemoteHandle ¶
func (*UnimplementedClusterServiceServer) RemoteHandle(context.Context, *RemoteMessage) (*Response, error)
type UnimplementedMasterServiceServer ¶
type UnimplementedMasterServiceServer struct { }
UnimplementedMasterServiceServer can be embedded to have forward compatible implementations.
func (*UnimplementedMasterServiceServer) Register ¶
func (*UnimplementedMasterServiceServer) Register(context.Context, *Member) (*MemberList, error)