Documentation ¶
Index ¶
- Constants
- Variables
- func BuildProxyRespHeader(resp *ProxyRespPackage, srvID uint32, callID uint32, errcode uint32, ...)
- func BuildRespHeader(resp *ResponsePackage, srvID uint32, callID uint32, errcode uint32)
- func PackLoggedOutMsg(resp *RpcLoggedOutPackage) ([]byte, int)
- func PackPingMsg(resp *RpcPingPackage) ([]byte, int)
- func PackPongMsg(resp *RpcPongPackage) ([]byte, int)
- func PackProxyReqMsg(req *ProxyRequestPackage) ([]byte, int)
- func PackProxyRespMsg(resp *ProxyRespPackage) ([]byte, int)
- func PackReqMsg(req *RequestPackage) ([]byte, int)
- func PackRespMsg(resp *ResponsePackage) ([]byte, int)
- func PackTimeMsg(resp *RpcTimeoutPackage) ([]byte, int)
- func SetProtocol(cusProto Protocol)
- type GlobalIndexType
- type Protocol
- type ProxyRequestPackage
- type ProxyRespPackage
- type RequestPackage
- type ResponsePackage
- type RpcCallHeader
- type RpcCallRetHeader
- type RpcCancelPackage
- type RpcCancelSubHeader
- type RpcLoggedOutHeader
- type RpcLoggedOutPackage
- type RpcMsgHeader
- type RpcPingHeader
- type RpcPingPackage
- type RpcPongHeader
- type RpcPongPackage
- type RpcProxyCallHeader
- type RpcProxyCallRetHeader
- type RpcPubHeader
- type RpcPubPackage
- type RpcSubHeader
- type RpcSubPackage
- type RpcTimeoutHeader
- type RpcTimeoutPackage
Constants ¶
View Source
const ( PACKAGE_ERROR = iota PACKAGE_FULL PACKAGE_LESS )
View Source
const ( RpcInvalidMsg uint32 = iota //0 无效类型 RequestMsg // 1 调用请求 ResponseMsg // 2 调用返回 ProxyRequestMsg // 3 proxy模式调用请求 ProxyResponseMsg // 4 proxy 模式请求回调 NotRpcMsg // 5 非RPC协议 RpcEventSub // 6 订阅事件 RpcEventPub // 7 发布事件 RpcEventCancel // 8 取消订阅 RpcCallAlias // 9 调用声明 RpcPing // 10 发送ping请求, 外部客户端到网关 RpcPong // 11 返回pong请求, 网关返回外部客户端 RpcTimeout // 12 ping pong 超时, 网关同步内部服务器 RpcLoggedOut // 13 外部连接强制下线操作 RpcProtocolMax // 10 最大有效协议范围 )
View Source
const ( IDL_SUCCESS uint32 = iota + 1 IDL_SERVICE_NOT_FOUND IDL_SERVICE_ERROR IDL_RPC_TIME_OUT IDL_RPC_LIMIT )
Variables ¶
Functions ¶
func BuildProxyRespHeader ¶
func BuildProxyRespHeader(resp *ProxyRespPackage, srvID uint32, callID uint32, errcode uint32, globalIndex GlobalIndexType)
func BuildRespHeader ¶
func BuildRespHeader(resp *ResponsePackage, srvID uint32, callID uint32, errcode uint32)
func PackLoggedOutMsg ¶
func PackLoggedOutMsg(resp *RpcLoggedOutPackage) ([]byte, int)
func PackPingMsg ¶
func PackPingMsg(resp *RpcPingPackage) ([]byte, int)
func PackPongMsg ¶
func PackPongMsg(resp *RpcPongPackage) ([]byte, int)
func PackProxyReqMsg ¶
func PackProxyReqMsg(req *ProxyRequestPackage) ([]byte, int)
func PackProxyRespMsg ¶
func PackProxyRespMsg(resp *ProxyRespPackage) ([]byte, int)
func PackReqMsg ¶
func PackReqMsg(req *RequestPackage) ([]byte, int)
func PackRespMsg ¶
func PackRespMsg(resp *ResponsePackage) ([]byte, int)
func PackTimeMsg ¶
func PackTimeMsg(resp *RpcTimeoutPackage) ([]byte, int)
func SetProtocol ¶
func SetProtocol(cusProto Protocol)
Types ¶
type Protocol ¶
type Protocol interface { ReadHeader(pkg []byte, header *RpcMsgHeader) bool ParsePlatoHeader(pkg []byte, header interface{}) bool ParseReqMsg(pkg []byte, header *RpcCallHeader) bool ParseProxyReqMsg([]byte, *RpcProxyCallHeader) bool ParseRespMsg(pkg []byte, header *RpcCallRetHeader) bool ParseProxyRespMsg([]byte, *RpcProxyCallRetHeader) bool ParseSubMsg([]byte, *RpcSubHeader) bool ParsePubMsg([]byte, *RpcPubHeader) bool ParseCancelMsg([]byte, *RpcCancelSubHeader) bool PackPlatoMsg(interface{}, []byte, int) ([]byte, int) PackRespMsg(resp *ResponsePackage) ([]byte, int) PackReqMsg(req *RequestPackage) ([]byte, int) PackProxyReqMsg(req *ProxyRequestPackage) ([]byte, int) PackProxyRespMsg(resp *ProxyRespPackage) ([]byte, int) PackSubMsg(header *RpcSubPackage) ([]byte, int) PackPubMsg(header *RpcPubPackage) ([]byte, int) PackCancelMsg(header *RpcCancelPackage) ([]byte, int) }
type ProxyRequestPackage ¶
type ProxyRequestPackage struct { Header *RpcProxyCallHeader Buffer []byte }
type ProxyRespPackage ¶
type ProxyRespPackage struct { Header *RpcProxyCallRetHeader Buffer []byte }
func BuildProxyNotFound ¶
func BuildProxyNotFound(req *RpcProxyCallHeader) (resp *ProxyRespPackage)
type RequestPackage ¶
type RequestPackage struct { Header *RpcCallHeader //请求协议头 Buffer []byte //协议提二进制数据, 可以对接pb 或者自己的结构体 }
type ResponsePackage ¶
type ResponsePackage struct { Header *RpcCallRetHeader //回包结构体 Buffer []byte //协议体二进制数据, 可以对接pb 或者自己的结构体 }
func BuildException ¶
func BuildException(callID uint32, pkg []byte) (resp *ResponsePackage)
BuildException build run exception response
func BuildNotFound ¶
func BuildNotFound(req *RpcCallHeader) (resp *ResponsePackage)
func BuildTimeOut ¶
func BuildTimeOut(callID uint32) (resp *ResponsePackage)
BuildTimeOut TODO use static variables
type RpcCallHeader ¶
type RpcCallHeader struct { RpcMsgHeader ServiceUUID uint64 //服务UUID ServerID uint32 //服务器实例ID CallID uint32 //代理调用id MethodID uint32 //方法id }
RpcMsgHeader 协议包头 协议类型 协议长度
func ReadCallHeader ¶
func ReadCallHeader(pkg []byte) *RpcCallHeader
type RpcCallRetHeader ¶
type RpcCallRetHeader struct { RpcMsgHeader ServerID uint32 CallID uint32 ErrorCode uint32 }
RpcMsgHeader 协议包头 协议类型 协议长度
func ReadRetHeader ¶
func ReadRetHeader(pkg []byte) *RpcCallRetHeader
type RpcCancelPackage ¶
type RpcCancelPackage struct { Header *RpcCancelSubHeader Buffer []byte }
type RpcCancelSubHeader ¶
type RpcCancelSubHeader struct { RpcMsgHeader SubId [16]byte //订阅id }
RpcCancelSubHeader 取消订阅消息头
type RpcLoggedOutHeader ¶
type RpcLoggedOutHeader struct { RpcMsgHeader GlobalIndexId GlobalIndexType }
RpcLoggedOutHeader 强制用户下线
func ReadLoggedOutHeader ¶
func ReadLoggedOutHeader(pkg []byte) *RpcLoggedOutHeader
type RpcLoggedOutPackage ¶
type RpcLoggedOutPackage struct {
Header *RpcLoggedOutHeader
}
type RpcMsgHeader ¶
RpcMsgHeader 协议包头 协议类型 协议长度
func ReadHeader ¶
func ReadHeader(pkg []byte) *RpcMsgHeader
type RpcPingHeader ¶
type RpcPingHeader struct { RpcMsgHeader PingId uint64 //ping id, 客户端第一次连接网关时候,赋值一次,可以用于定时器轮询 }
RpcPingHeader 心跳包,client --> gateway
func ReadPingHeader ¶
func ReadPingHeader(pkg []byte) *RpcPingHeader
type RpcPingPackage ¶
type RpcPingPackage struct {
Header *RpcPingHeader
}
type RpcPongHeader ¶
type RpcPongHeader struct { RpcMsgHeader PingId uint64 //ping id, 客户端第一次连接网关时候,赋值一次,可以用于定时器轮询 }
RpcPongHeader 心跳包,gateway --> client
type RpcPongPackage ¶
type RpcPongPackage struct {
Header *RpcPongHeader
}
type RpcProxyCallHeader ¶
type RpcProxyCallHeader struct { RpcMsgHeader ServiceUUID uint64 //服务UUID ServerID uint32 //服务器实例ID CallID uint32 //代理调用id MethodID uint32 //方法id GlobalIndex GlobalIndexType //代理节点标识 OneWay uint16 // 是否是one way节点 }
RpcMsgHeader 协议包头 协议类型 协议长度
func BuildProxyCallHeader ¶
func BuildProxyCallHeader(header *RpcCallHeader, globalIndex GlobalIndexType) *RpcProxyCallHeader
func ReadProxyCallHeader ¶
func ReadProxyCallHeader(pkg []byte) *RpcProxyCallHeader
type RpcProxyCallRetHeader ¶
type RpcProxyCallRetHeader struct { RpcMsgHeader ServerID uint32 //服务实例id CallID uint32 //调用id对端赋值 ErrorCode uint32 //错误代码 GlobalIndex GlobalIndexType //代理节点标识 }
RpcMsgHeader 协议包头 协议类型 协议长度
func ReadProxyRetHeader ¶
func ReadProxyRetHeader(pkg []byte) *RpcProxyCallRetHeader
type RpcPubHeader ¶
type RpcPubHeader struct { RpcMsgHeader SubId [16]byte //订阅id ProxyId uint32 //代理id ValueLen uint32 //附带数据长度 }
RpcPubHeader 发布事件消息头
type RpcPubPackage ¶
type RpcPubPackage struct { Header *RpcPubHeader Buffer []byte }
type RpcSubHeader ¶
type RpcSubHeader struct { RpcMsgHeader SubId [16]byte //订阅id ProxyId uint32 //代理id ServiceUUID uint64 //服务uid ServiceID uint32 //服务势力id NameLen uint32 //事件名称长度 DataLen uint32 //数目长度 }
RpcSubHeader 订阅事件消息头
type RpcSubPackage ¶
type RpcSubPackage struct { Header *RpcSubHeader Buffer []byte }
type RpcTimeoutHeader ¶
type RpcTimeoutHeader struct { RpcMsgHeader GlobalIndexId GlobalIndexType // 网关唯一 id }
RpcTimeoutHeader 断线时,网关通知内部服务,外部连接断开
func ReadTimeoutHeader ¶
func ReadTimeoutHeader(pkg []byte) *RpcTimeoutHeader
type RpcTimeoutPackage ¶
type RpcTimeoutPackage struct {
Header *RpcTimeoutHeader
}
Click to show internal directories.
Click to hide internal directories.