Documentation ¶
Index ¶
- Constants
- Variables
- func BuildRespHeader(resp *ResponsePackage, srvID uint32, callID uint32, errcode uint32)
- func PackReqMsg(req *RequestPackage) ([]byte, int)
- func PackRespMsg(resp *ResponsePackage) ([]byte, int)
- func SetProtocl(cus_proto Protocol)
- type Protocol
- type RequestPackage
- type ResponsePackage
- type RpcCallHeader
- type RpcCallRetHeader
- type RpcMsgHeader
Constants ¶
View Source
const ( PACKAGE_ERROR = iota PACKAGE_FULL PACKAGE_LESS )
View Source
const ( INVALID_MSG uint32 = iota //0 无效类型 REQUEST_MSG // 1 调用请求 RESPONESE_MSG // 2 调用返回 NOTRPC_MSG // 3 非RPC协议 )
View Source
const ( IDL_SUCCESS uint32 = iota + 1 IDL_SERVICE_NOT_FOUND IDL_SERVICE_ERROR IDL_RPC_TIME_OUT )
View Source
const ( SERVICE_RESOLVED = iota + 1 //状态 SERVICE_UPDATING )
Variables ¶
View Source
var ( RpcHeadSize int CallHeadSize int RespHeadSize int )
Functions ¶
func BuildRespHeader ¶
func BuildRespHeader(resp *ResponsePackage, srvID uint32, callID uint32, errcode uint32)
func PackReqMsg ¶
func PackReqMsg(req *RequestPackage) ([]byte, int)
func PackRespMsg ¶
func PackRespMsg(resp *ResponsePackage) ([]byte, int)
func SetProtocl ¶
func SetProtocl(cus_proto Protocol)
Types ¶
type Protocol ¶
type Protocol interface { ReadHeader(pkg []byte, header *RpcMsgHeader) bool ParseReqMsg(pkg []byte, header *RpcCallHeader) bool ParseRespMsg(pkg []byte, header *RpcCallRetHeader) bool PackRespMsg(resp *ResponsePackage) ([]byte, int) PackReqMsg(req *RequestPackage) ([]byte, int) }
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) (resp *ResponsePackage)
BuildException build run exception response
func BuildNotFount ¶
func BuildNotFount(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 }
func ReadCallHeader ¶
func ReadCallHeader(pkg []byte) *RpcCallHeader
type RpcCallRetHeader ¶
type RpcCallRetHeader struct { RpcMsgHeader ServerID uint32 CallID uint32 ErrorCode uint32 }
func ReadRetHeader ¶
func ReadRetHeader(pkg []byte) *RpcCallRetHeader
Click to show internal directories.
Click to hide internal directories.