Documentation ¶
Overview ¶
Package pkg is a generated protocol buffer package.
It is generated from these files:
pkg.ErrorMessage.proto pkg.HandShake.proto
It has these top-level messages:
ErrorMessage HostPort HandShakeClientData HandShakeResponse
Package pkg defines data structures pass through network ¶
Package pkg defines data structures pass through network
Index ¶
- Constants
- Variables
- func ReadHeader(reader io.Reader, header *Header) (int, error)
- func SetHandShakeImpl(hs HandShake) error
- func UnmarshalDynamicHeader(data []byte, header *Header) (int, error)
- func UnmarshalHeader(buffer []byte, header *Header) (int, error)
- func UnmarshalStaticHeader(data []byte, header *Header) (int, error)
- type EncodingType
- type ErrorMessage
- type HandShake
- type HandShakeClientData
- func (*HandShakeClientData) Descriptor() ([]byte, []int)
- func (m *HandShakeClientData) GetClientType() string
- func (m *HandShakeClientData) GetClientVersion() string
- func (m *HandShakeClientData) GetDictMd5() string
- func (*HandShakeClientData) ProtoMessage()
- func (m *HandShakeClientData) Reset()
- func (m *HandShakeClientData) String() string
- type HandShakeImpl
- func (r *HandShakeImpl) AddRoutesMap(route string)
- func (r *HandShakeImpl) ConvertRouteIndexFromRpc(route string) (RouteIndex, bool)
- func (r *HandShakeImpl) ConvertRouteIndexToRpc(route string) (RouteIndex, bool)
- func (r *HandShakeImpl) GetIndexRoute(str string) (RouteIndex, bool)
- func (r *HandShakeImpl) GetStringRoute(idx RouteIndex) (string, bool)
- func (r *HandShakeImpl) MergeRpcRoutesMap(data RouteMap)
- func (r *HandShakeImpl) RegistSpecRoute(route string, idx RouteIndex) error
- func (r *HandShakeImpl) RoutesMap() RouteMap
- func (r *HandShakeImpl) RpcRoutesMap() RouteMap
- func (r *HandShakeImpl) SpecRoutesMap() RouteMap
- func (r *HandShakeImpl) UpdateHandShakeResponse(resp *HandShakeResponse)
- type HandShakeResponse
- func (*HandShakeResponse) Descriptor() ([]byte, []int)
- func (m *HandShakeResponse) GetHeartBeatRate() int32
- func (m *HandShakeResponse) GetIsReconnect() bool
- func (m *HandShakeResponse) GetNow() string
- func (m *HandShakeResponse) GetReconnectTo() *HostPort
- func (m *HandShakeResponse) GetRoutes() map[string]uint32
- func (m *HandShakeResponse) GetServerVersion() string
- func (*HandShakeResponse) ProtoMessage()
- func (m *HandShakeResponse) Reset()
- func (m *HandShakeResponse) String() string
- type Header
- func NewHandShakeHeader(e EncodingType) *Header
- func NewHandShakeResponseHeader(h *Header) *Header
- func NewHeader(t PackageType, e EncodingType, idGen *IDGen, r string) *Header
- func NewHeaderFromRpc(h *Header) *Header
- func NewHeartBeatHeader(idGen *IDGen) *Header
- func NewHeartBeatResponseHeader(h *Header) *Header
- func NewRpcHeader(h *Header, clientId uint32) *Header
- type HostPort
- type IDGen
- type PackageIDType
- type PackageSizeType
- type PackageType
- type RouteIndex
- type RouteMap
- type Status
Constants ¶
View Source
const ( HEADER_STATIC_SIZE = 6 INT_BYTE_SIZE = 4 )
Variables ¶
View Source
var Status_name = map[int32]string{
0: "OK",
144: "ERR",
145: "ERR_WRONG_PARAMS",
146: "ERR_DECODE_FAILED",
147: "ERR_TIMEOUT",
148: "ERR_EMPTY_RESULT",
}
View Source
var Status_value = map[string]int32{
"OK": 0,
"ERR": 144,
"ERR_WRONG_PARAMS": 145,
"ERR_DECODE_FAILED": 146,
"ERR_TIMEOUT": 147,
"ERR_EMPTY_RESULT": 148,
}
Functions ¶
func SetHandShakeImpl ¶
Types ¶
type EncodingType ¶
type EncodingType byte
const ( ENCODING_NONE EncodingType = 0x00 ENCODING_GOB EncodingType = 0x01 ENCODING_JSON EncodingType = 0x02 ENCODING_BSON EncodingType = 0x03 ENCODING_PROTOBUF EncodingType = 0x04 )
func (EncodingType) String ¶
func (i EncodingType) String() string
type ErrorMessage ¶
type ErrorMessage struct { Code Status `protobuf:"varint,1,opt,name=Code,enum=pkg.Status" json:"Code,omitempty"` Message string `protobuf:"bytes,2,opt,name=Message" json:"Message,omitempty"` }
func NewErrorMessage ¶
func NewErrorMessage(code Status, msg string) *ErrorMessage
func (*ErrorMessage) Descriptor ¶
func (*ErrorMessage) Descriptor() ([]byte, []int)
func (ErrorMessage) Error ¶
func (self ErrorMessage) Error() string
func (*ErrorMessage) GetCode ¶
func (m *ErrorMessage) GetCode() Status
func (*ErrorMessage) GetMessage ¶
func (m *ErrorMessage) GetMessage() string
func (*ErrorMessage) ProtoMessage ¶
func (*ErrorMessage) ProtoMessage()
func (*ErrorMessage) Reset ¶
func (m *ErrorMessage) Reset()
func (*ErrorMessage) String ¶
func (m *ErrorMessage) String() string
type HandShake ¶
type HandShake interface { RegistSpecRoute(route string, idx RouteIndex) error MergeRpcRoutesMap(data RouteMap) AddRoutesMap(data string) UpdateHandShakeResponse(resp *HandShakeResponse) RoutesMap() RouteMap RpcRoutesMap() RouteMap SpecRoutesMap() RouteMap GetIndexRoute(str string) (RouteIndex, bool) GetStringRoute(idx RouteIndex) (string, bool) ConvertRouteIndexToRpc(route string) (RouteIndex, bool) ConvertRouteIndexFromRpc(route string) (RouteIndex, bool) }
func DefaultHandShake ¶
func DefaultHandShake() HandShake
type HandShakeClientData ¶
type HandShakeClientData struct { ClientType string `protobuf:"bytes,1,opt,name=ClientType" json:"ClientType,omitempty"` ClientVersion string `protobuf:"bytes,2,opt,name=ClientVersion" json:"ClientVersion,omitempty"` DictMd5 string `protobuf:"bytes,3,opt,name=DictMd5" json:"DictMd5,omitempty"` }
func (*HandShakeClientData) Descriptor ¶
func (*HandShakeClientData) Descriptor() ([]byte, []int)
func (*HandShakeClientData) GetClientType ¶
func (m *HandShakeClientData) GetClientType() string
func (*HandShakeClientData) GetClientVersion ¶
func (m *HandShakeClientData) GetClientVersion() string
func (*HandShakeClientData) GetDictMd5 ¶
func (m *HandShakeClientData) GetDictMd5() string
func (*HandShakeClientData) ProtoMessage ¶
func (*HandShakeClientData) ProtoMessage()
func (*HandShakeClientData) Reset ¶
func (m *HandShakeClientData) Reset()
func (*HandShakeClientData) String ¶
func (m *HandShakeClientData) String() string
type HandShakeImpl ¶
type HandShakeImpl struct {
// contains filtered or unexported fields
}
func NewHandShakeImpl ¶
func NewHandShakeImpl() *HandShakeImpl
func (*HandShakeImpl) AddRoutesMap ¶
func (r *HandShakeImpl) AddRoutesMap(route string)
func (*HandShakeImpl) ConvertRouteIndexFromRpc ¶
func (r *HandShakeImpl) ConvertRouteIndexFromRpc(route string) (RouteIndex, bool)
func (*HandShakeImpl) ConvertRouteIndexToRpc ¶
func (r *HandShakeImpl) ConvertRouteIndexToRpc(route string) (RouteIndex, bool)
func (*HandShakeImpl) GetIndexRoute ¶
func (r *HandShakeImpl) GetIndexRoute(str string) (RouteIndex, bool)
func (*HandShakeImpl) GetStringRoute ¶
func (r *HandShakeImpl) GetStringRoute(idx RouteIndex) (string, bool)
func (*HandShakeImpl) MergeRpcRoutesMap ¶
func (r *HandShakeImpl) MergeRpcRoutesMap(data RouteMap)
func (*HandShakeImpl) RegistSpecRoute ¶
func (r *HandShakeImpl) RegistSpecRoute(route string, idx RouteIndex) error
func (*HandShakeImpl) RoutesMap ¶
func (r *HandShakeImpl) RoutesMap() RouteMap
func (*HandShakeImpl) RpcRoutesMap ¶
func (r *HandShakeImpl) RpcRoutesMap() RouteMap
func (*HandShakeImpl) SpecRoutesMap ¶
func (r *HandShakeImpl) SpecRoutesMap() RouteMap
func (*HandShakeImpl) UpdateHandShakeResponse ¶
func (r *HandShakeImpl) UpdateHandShakeResponse(resp *HandShakeResponse)
type HandShakeResponse ¶
type HandShakeResponse struct { ServerVersion string `protobuf:"bytes,1,opt,name=ServerVersion" json:"ServerVersion,omitempty"` Now string `protobuf:"bytes,2,opt,name=Now" json:"Now,omitempty"` HeartBeatRate int32 `protobuf:"varint,3,opt,name=HeartBeatRate" json:"HeartBeatRate,omitempty"` Routes map[string]uint32 `` /* 133-byte string literal not displayed */ IsReconnect bool `protobuf:"varint,5,opt,name=IsReconnect" json:"IsReconnect,omitempty"` ReconnectTo *HostPort `protobuf:"bytes,6,opt,name=ReconnectTo" json:"ReconnectTo,omitempty"` }
func (*HandShakeResponse) Descriptor ¶
func (*HandShakeResponse) Descriptor() ([]byte, []int)
func (*HandShakeResponse) GetHeartBeatRate ¶
func (m *HandShakeResponse) GetHeartBeatRate() int32
func (*HandShakeResponse) GetIsReconnect ¶
func (m *HandShakeResponse) GetIsReconnect() bool
func (*HandShakeResponse) GetNow ¶
func (m *HandShakeResponse) GetNow() string
func (*HandShakeResponse) GetReconnectTo ¶
func (m *HandShakeResponse) GetReconnectTo() *HostPort
func (*HandShakeResponse) GetRoutes ¶
func (m *HandShakeResponse) GetRoutes() map[string]uint32
func (*HandShakeResponse) GetServerVersion ¶
func (m *HandShakeResponse) GetServerVersion() string
func (*HandShakeResponse) ProtoMessage ¶
func (*HandShakeResponse) ProtoMessage()
func (*HandShakeResponse) Reset ¶
func (m *HandShakeResponse) Reset()
func (*HandShakeResponse) String ¶
func (m *HandShakeResponse) String() string
type Header ¶
type Header struct { Type PackageType Encoding EncodingType ID PackageIDType Status Status ContentSize PackageSizeType Route string RouteEncoded RouteIndex ClientID uint32 /* rpc only */ }
func NewHandShakeHeader ¶
func NewHandShakeHeader(e EncodingType) *Header
func NewHeader ¶
func NewHeader(t PackageType, e EncodingType, idGen *IDGen, r string) *Header
func NewHeaderFromRpc ¶
func NewHeartBeatHeader ¶
func NewRpcHeader ¶
type HostPort ¶
type HostPort struct { Host string `protobuf:"bytes,1,opt,name=Host" json:"Host,omitempty"` Port int32 `protobuf:"varint,2,opt,name=Port" json:"Port,omitempty"` }
func (*HostPort) Descriptor ¶
func (*HostPort) ProtoMessage ¶
func (*HostPort) ProtoMessage()
type PackageIDType ¶
type PackageIDType byte
type PackageSizeType ¶
type PackageSizeType uint16
type PackageType ¶
type PackageType byte
const ( PKG_NOTIFY PackageType = 0x00 PKG_REQUEST PackageType = 0x01 PKG_RESPONSE PackageType = 0x02 PKG_PUSH PackageType = 0x03 PKG_HEARTBEAT PackageType = 0x04 PKG_HEARTBEAT_RESPONSE PackageType = 0x05 PKG_HAND_SHAKE PackageType = 0x06 PKG_HAND_SHAKE_RESPONSE PackageType = 0x07 PKG_RPC = 0x10 PKG_RPC_NOTIFY PackageType = PKG_RPC | PKG_NOTIFY PKG_RPC_REQUEST PackageType = PKG_RPC | PKG_REQUEST PKG_RPC_RESPONSE PackageType = PKG_RPC | PKG_RESPONSE PKG_RPC_PUSH PackageType = PKG_RPC | PKG_PUSH PKG_RPC_HAND_SHAKE PackageType = PKG_RPC | PKG_HAND_SHAKE PKG_RPC_HAND_SHAKE_RESPONSE PackageType = PKG_RPC | PKG_HAND_SHAKE_RESPONSE PKG_RPC_BROADCAST PackageType = PKG_RPC | 0x08 )
func (PackageType) HasResponse ¶
func (t PackageType) HasResponse() bool
func (PackageType) IsRPC ¶
func (t PackageType) IsRPC() bool
func (PackageType) String ¶
func (i PackageType) String() string
func (PackageType) ToResponse ¶
func (t PackageType) ToResponse() PackageType
type RouteMap ¶
type RouteMap map[string]RouteIndex
func NewRouteMap ¶
func NewRouteMap() RouteMap
func (RouteMap) Add ¶
func (rm RouteMap) Add(route string, encoded RouteIndex)
func (RouteMap) GetIndexRoute ¶
func (r RouteMap) GetIndexRoute(str string) (RouteIndex, bool)
func (RouteMap) GetStringRoute ¶
func (r RouteMap) GetStringRoute(idx RouteIndex) (string, bool)
Click to show internal directories.
Click to hide internal directories.