pkg

package
v0.0.0-...-c340371 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 6 Imported by: 25

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

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 ReadHeader

func ReadHeader(reader io.Reader, header *Header) (int, error)

func SetHandShakeImpl

func SetHandShakeImpl(hs HandShake) error

func UnmarshalDynamicHeader

func UnmarshalDynamicHeader(data []byte, header *Header) (int, error)

func UnmarshalHeader

func UnmarshalHeader(buffer []byte, header *Header) (int, error)

func UnmarshalStaticHeader

func UnmarshalStaticHeader(data []byte, header *Header) (int, error)

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 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 NewHandShakeResponseHeader

func NewHandShakeResponseHeader(h *Header) *Header

func NewHeader

func NewHeader(t PackageType, e EncodingType, idGen *IDGen, r string) *Header

func NewHeaderFromRpc

func NewHeaderFromRpc(h *Header) *Header

func NewHeartBeatHeader

func NewHeartBeatHeader(idGen *IDGen) *Header

func NewHeartBeatResponseHeader

func NewHeartBeatResponseHeader(h *Header) *Header

func NewRpcHeader

func NewRpcHeader(h *Header, clientId uint32) *Header

func (*Header) Marshal

func (self *Header) Marshal() ([]byte, error)

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) Descriptor() ([]byte, []int)

func (*HostPort) GetHost

func (m *HostPort) GetHost() string

func (*HostPort) GetPort

func (m *HostPort) GetPort() int32

func (*HostPort) ProtoMessage

func (*HostPort) ProtoMessage()

func (*HostPort) Reset

func (m *HostPort) Reset()

func (*HostPort) String

func (m *HostPort) String() string

type IDGen

type IDGen struct {
	*helpers.IDGen
}

func NewIDGen

func NewIDGen() *IDGen

func (*IDGen) NextID

func (self *IDGen) NextID() PackageIDType

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 RouteIndex

type RouteIndex uint16
const (
	ROUTE_INDEX_NONE RouteIndex = 0
)

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)

func (RouteMap) IsEmpty

func (rm RouteMap) IsEmpty() bool

func (RouteMap) Merge

func (rm RouteMap) Merge(data RouteMap)

type Status

type Status int32
const (
	Status_OK                Status = 0
	Status_ERR               Status = 144
	Status_ERR_WRONG_PARAMS  Status = 145
	Status_ERR_DECODE_FAILED Status = 146
	Status_ERR_TIMEOUT       Status = 147
	Status_ERR_EMPTY_RESULT  Status = 148
)

func (Status) EnumDescriptor

func (Status) EnumDescriptor() ([]byte, []int)

func (Status) String

func (x Status) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL