Documentation
¶
Index ¶
- Constants
- Variables
- func CalcDelay(tempDelay time.Duration) time.Duration
- func CatchExitSignal(p Stopper)
- func CtxGetLock(ctx context.Context) *sync.Mutex
- func CtxWithLock(ctx context.Context, mux *sync.Mutex) context.Context
- func GetBytesBuf() *bytes.Buffer
- func GetProtoBuf() *proto.Buffer
- func IsClose(err error) bool
- func IsClosedNetworkError(err error) bool
- func IsRespMethod(m string) bool
- func IsTemporary(err error) bool
- func PutBytesBuf(buf *bytes.Buffer)
- func PutProtoBuf(buf *proto.Buffer)
- func Send(ctx context.Context, conn net.Conn, header RpcHeader, msg proto.Message) error
- func Sleep(tempDelay time.Duration, cancel <-chan struct{})
- func WriteHTTPError(w http.ResponseWriter, error string, code int) error
- type AckCode
- type AckResponse
- func (*AckResponse) Descriptor() ([]byte, []int)
- func (m *AckResponse) GetCode() AckCode
- func (*AckResponse) ProtoMessage()
- func (m *AckResponse) Reset()
- func (m *AckResponse) String() string
- func (m *AckResponse) XXX_DiscardUnknown()
- func (m *AckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *AckResponse) XXX_Merge(src proto.Message)
- func (m *AckResponse) XXX_Size() int
- func (m *AckResponse) XXX_Unmarshal(b []byte) error
- type HeartbeatPkg
- func (*HeartbeatPkg) Descriptor() ([]byte, []int)
- func (m *HeartbeatPkg) GetTimestamp() int64
- func (*HeartbeatPkg) ProtoMessage()
- func (m *HeartbeatPkg) Reset()
- func (m *HeartbeatPkg) String() string
- func (m *HeartbeatPkg) XXX_DiscardUnknown()
- func (m *HeartbeatPkg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *HeartbeatPkg) XXX_Merge(src proto.Message)
- func (m *HeartbeatPkg) XXX_Size() int
- func (m *HeartbeatPkg) XXX_Unmarshal(b []byte) error
- type HttpRequest
- func (*HttpRequest) Descriptor() ([]byte, []int)
- func (m *HttpRequest) GetBody() []byte
- func (m *HttpRequest) GetHeader() []*HttpRequest_Header
- func (m *HttpRequest) GetHost() string
- func (m *HttpRequest) GetMethod() string
- func (m *HttpRequest) GetRemoteAddr() string
- func (m *HttpRequest) GetReqProto() string
- func (m *HttpRequest) GetUrl() string
- func (*HttpRequest) ProtoMessage()
- func (m *HttpRequest) Reset()
- func (m *HttpRequest) String() string
- func (m *HttpRequest) XXX_DiscardUnknown()
- func (m *HttpRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *HttpRequest) XXX_Merge(src proto.Message)
- func (m *HttpRequest) XXX_Size() int
- func (m *HttpRequest) XXX_Unmarshal(b []byte) error
- type HttpRequest_Header
- func (*HttpRequest_Header) Descriptor() ([]byte, []int)
- func (m *HttpRequest_Header) GetKey() string
- func (m *HttpRequest_Header) GetValue() []string
- func (*HttpRequest_Header) ProtoMessage()
- func (m *HttpRequest_Header) Reset()
- func (m *HttpRequest_Header) String() string
- func (m *HttpRequest_Header) XXX_DiscardUnknown()
- func (m *HttpRequest_Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *HttpRequest_Header) XXX_Merge(src proto.Message)
- func (m *HttpRequest_Header) XXX_Size() int
- func (m *HttpRequest_Header) XXX_Unmarshal(b []byte) error
- type HttpResponse
- func (*HttpResponse) Descriptor() ([]byte, []int)
- func (m *HttpResponse) GetBody() []byte
- func (m *HttpResponse) GetHeader() []*HttpRequest_Header
- func (m *HttpResponse) GetNotFinish() bool
- func (m *HttpResponse) GetStatus() int32
- func (*HttpResponse) ProtoMessage()
- func (m *HttpResponse) Reset()
- func (m *HttpResponse) String() string
- func (m *HttpResponse) XXX_DiscardUnknown()
- func (m *HttpResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *HttpResponse) XXX_Merge(src proto.Message)
- func (m *HttpResponse) XXX_Size() int
- func (m *HttpResponse) XXX_Unmarshal(b []byte) error
- type LoginRequest
- func (*LoginRequest) Descriptor() ([]byte, []int)
- func (m *LoginRequest) GetName() string
- func (m *LoginRequest) GetRespSeq() int32
- func (*LoginRequest) ProtoMessage()
- func (m *LoginRequest) Reset()
- func (m *LoginRequest) String() string
- func (m *LoginRequest) XXX_DiscardUnknown()
- func (m *LoginRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *LoginRequest) XXX_Merge(src proto.Message)
- func (m *LoginRequest) XXX_Size() int
- func (m *LoginRequest) XXX_Unmarshal(b []byte) error
- type MessageReceiver
- type NetError
- type RpcHeader
- func (*RpcHeader) Descriptor() ([]byte, []int)
- func (m *RpcHeader) GetError() string
- func (m *RpcHeader) GetMethod() string
- func (m *RpcHeader) GetSeq() int32
- func (*RpcHeader) ProtoMessage()
- func (m *RpcHeader) Reset()
- func (m *RpcHeader) String() string
- func (m *RpcHeader) XXX_DiscardUnknown()
- func (m *RpcHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *RpcHeader) XXX_Merge(src proto.Message)
- func (m *RpcHeader) XXX_Size() int
- func (m *RpcHeader) XXX_Unmarshal(b []byte) error
- type RpcMessage
- type Stopper
- type Temporary
Constants ¶
View Source
const ( RpcBeginFlag uint32 = 0xFFF62556 DefaultMsgSize = 1024 MaxReceiveSize = 1024 * 1024 * 50 )
View Source
const ( RespMethodPrefix = "RESP_" MethodLogin = "login" MethodHeartbeat = "hb" MethodHttpDo = "http" RespMethodLogin = RespMethodPrefix + MethodLogin RespMethodHeartbeat = RespMethodPrefix + MethodHeartbeat RespMethodHttpDo = RespMethodPrefix + MethodHttpDo PortalHeaderPrefix = "Portal-" PortalHeaderDeep = PortalHeaderPrefix + "Deep" PortalHeaderHost = PortalHeaderPrefix + "Host" )
Variables ¶
View Source
var AckCode_name = map[int32]string{
0: "Success",
1: "NotLogin",
2: "Error",
}
View Source
var AckCode_value = map[string]int32{
"Success": 0,
"NotLogin": 1,
"Error": 2,
}
View Source
var HeartbeatInterval = 10 * time.Second
Functions ¶
func CatchExitSignal ¶
func CatchExitSignal(p Stopper)
func GetBytesBuf ¶
func GetProtoBuf ¶
func IsClosedNetworkError ¶
func IsRespMethod ¶
func IsTemporary ¶
func PutBytesBuf ¶
func PutProtoBuf ¶
func WriteHTTPError ¶
func WriteHTTPError(w http.ResponseWriter, error string, code int) error
Types ¶
type AckResponse ¶
type AckResponse struct {
Code AckCode `protobuf:"varint,1,opt,name=code,proto3,enum=core.AckCode" json:"code,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*AckResponse) Descriptor ¶
func (*AckResponse) Descriptor() ([]byte, []int)
func (*AckResponse) GetCode ¶
func (m *AckResponse) GetCode() AckCode
func (*AckResponse) ProtoMessage ¶
func (*AckResponse) ProtoMessage()
func (*AckResponse) Reset ¶
func (m *AckResponse) Reset()
func (*AckResponse) String ¶
func (m *AckResponse) String() string
func (*AckResponse) XXX_DiscardUnknown ¶
func (m *AckResponse) XXX_DiscardUnknown()
func (*AckResponse) XXX_Marshal ¶
func (m *AckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*AckResponse) XXX_Merge ¶
func (m *AckResponse) XXX_Merge(src proto.Message)
func (*AckResponse) XXX_Size ¶
func (m *AckResponse) XXX_Size() int
func (*AckResponse) XXX_Unmarshal ¶
func (m *AckResponse) XXX_Unmarshal(b []byte) error
type HeartbeatPkg ¶
type HeartbeatPkg struct {
Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*HeartbeatPkg) Descriptor ¶
func (*HeartbeatPkg) Descriptor() ([]byte, []int)
func (*HeartbeatPkg) GetTimestamp ¶
func (m *HeartbeatPkg) GetTimestamp() int64
func (*HeartbeatPkg) ProtoMessage ¶
func (*HeartbeatPkg) ProtoMessage()
func (*HeartbeatPkg) Reset ¶
func (m *HeartbeatPkg) Reset()
func (*HeartbeatPkg) String ¶
func (m *HeartbeatPkg) String() string
func (*HeartbeatPkg) XXX_DiscardUnknown ¶
func (m *HeartbeatPkg) XXX_DiscardUnknown()
func (*HeartbeatPkg) XXX_Marshal ¶
func (m *HeartbeatPkg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*HeartbeatPkg) XXX_Merge ¶
func (m *HeartbeatPkg) XXX_Merge(src proto.Message)
func (*HeartbeatPkg) XXX_Size ¶
func (m *HeartbeatPkg) XXX_Size() int
func (*HeartbeatPkg) XXX_Unmarshal ¶
func (m *HeartbeatPkg) XXX_Unmarshal(b []byte) error
type HttpRequest ¶
type HttpRequest struct {
Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
ReqProto string `protobuf:"bytes,3,opt,name=req_proto,json=reqProto,proto3" json:"req_proto,omitempty"`
Header []*HttpRequest_Header `protobuf:"bytes,4,rep,name=header,proto3" json:"header,omitempty"`
Body []byte `protobuf:"bytes,5,opt,name=body,proto3" json:"body,omitempty"`
Host string `protobuf:"bytes,6,opt,name=host,proto3" json:"host,omitempty"`
RemoteAddr string `protobuf:"bytes,7,opt,name=remote_addr,json=remoteAddr,proto3" json:"remote_addr,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*HttpRequest) Descriptor ¶
func (*HttpRequest) Descriptor() ([]byte, []int)
func (*HttpRequest) GetBody ¶
func (m *HttpRequest) GetBody() []byte
func (*HttpRequest) GetHeader ¶
func (m *HttpRequest) GetHeader() []*HttpRequest_Header
func (*HttpRequest) GetHost ¶
func (m *HttpRequest) GetHost() string
func (*HttpRequest) GetMethod ¶
func (m *HttpRequest) GetMethod() string
func (*HttpRequest) GetRemoteAddr ¶
func (m *HttpRequest) GetRemoteAddr() string
func (*HttpRequest) GetReqProto ¶
func (m *HttpRequest) GetReqProto() string
func (*HttpRequest) GetUrl ¶
func (m *HttpRequest) GetUrl() string
func (*HttpRequest) ProtoMessage ¶
func (*HttpRequest) ProtoMessage()
func (*HttpRequest) Reset ¶
func (m *HttpRequest) Reset()
func (*HttpRequest) String ¶
func (m *HttpRequest) String() string
func (*HttpRequest) XXX_DiscardUnknown ¶
func (m *HttpRequest) XXX_DiscardUnknown()
func (*HttpRequest) XXX_Marshal ¶
func (m *HttpRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*HttpRequest) XXX_Merge ¶
func (m *HttpRequest) XXX_Merge(src proto.Message)
func (*HttpRequest) XXX_Size ¶
func (m *HttpRequest) XXX_Size() int
func (*HttpRequest) XXX_Unmarshal ¶
func (m *HttpRequest) XXX_Unmarshal(b []byte) error
type HttpRequest_Header ¶
type HttpRequest_Header struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Value []string `protobuf:"bytes,2,rep,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*HttpRequest_Header) Descriptor ¶
func (*HttpRequest_Header) Descriptor() ([]byte, []int)
func (*HttpRequest_Header) GetKey ¶
func (m *HttpRequest_Header) GetKey() string
func (*HttpRequest_Header) GetValue ¶
func (m *HttpRequest_Header) GetValue() []string
func (*HttpRequest_Header) ProtoMessage ¶
func (*HttpRequest_Header) ProtoMessage()
func (*HttpRequest_Header) Reset ¶
func (m *HttpRequest_Header) Reset()
func (*HttpRequest_Header) String ¶
func (m *HttpRequest_Header) String() string
func (*HttpRequest_Header) XXX_DiscardUnknown ¶
func (m *HttpRequest_Header) XXX_DiscardUnknown()
func (*HttpRequest_Header) XXX_Marshal ¶
func (m *HttpRequest_Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*HttpRequest_Header) XXX_Merge ¶
func (m *HttpRequest_Header) XXX_Merge(src proto.Message)
func (*HttpRequest_Header) XXX_Size ¶
func (m *HttpRequest_Header) XXX_Size() int
func (*HttpRequest_Header) XXX_Unmarshal ¶
func (m *HttpRequest_Header) XXX_Unmarshal(b []byte) error
type HttpResponse ¶
type HttpResponse struct {
Status int32 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"`
Header []*HttpRequest_Header `protobuf:"bytes,2,rep,name=header,proto3" json:"header,omitempty"`
Body []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
NotFinish bool `protobuf:"varint,4,opt,name=not_finish,json=notFinish,proto3" json:"not_finish,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*HttpResponse) Descriptor ¶
func (*HttpResponse) Descriptor() ([]byte, []int)
func (*HttpResponse) GetBody ¶
func (m *HttpResponse) GetBody() []byte
func (*HttpResponse) GetHeader ¶
func (m *HttpResponse) GetHeader() []*HttpRequest_Header
func (*HttpResponse) GetNotFinish ¶
func (m *HttpResponse) GetNotFinish() bool
func (*HttpResponse) GetStatus ¶
func (m *HttpResponse) GetStatus() int32
func (*HttpResponse) ProtoMessage ¶
func (*HttpResponse) ProtoMessage()
func (*HttpResponse) Reset ¶
func (m *HttpResponse) Reset()
func (*HttpResponse) String ¶
func (m *HttpResponse) String() string
func (*HttpResponse) XXX_DiscardUnknown ¶
func (m *HttpResponse) XXX_DiscardUnknown()
func (*HttpResponse) XXX_Marshal ¶
func (m *HttpResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*HttpResponse) XXX_Merge ¶
func (m *HttpResponse) XXX_Merge(src proto.Message)
func (*HttpResponse) XXX_Size ¶
func (m *HttpResponse) XXX_Size() int
func (*HttpResponse) XXX_Unmarshal ¶
func (m *HttpResponse) XXX_Unmarshal(b []byte) error
type LoginRequest ¶
type LoginRequest struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
RespSeq int32 `protobuf:"varint,2,opt,name=resp_seq,json=respSeq,proto3" json:"resp_seq,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*LoginRequest) Descriptor ¶
func (*LoginRequest) Descriptor() ([]byte, []int)
func (*LoginRequest) GetName ¶
func (m *LoginRequest) GetName() string
func (*LoginRequest) GetRespSeq ¶
func (m *LoginRequest) GetRespSeq() int32
func (*LoginRequest) ProtoMessage ¶
func (*LoginRequest) ProtoMessage()
func (*LoginRequest) Reset ¶
func (m *LoginRequest) Reset()
func (*LoginRequest) String ¶
func (m *LoginRequest) String() string
func (*LoginRequest) XXX_DiscardUnknown ¶
func (m *LoginRequest) XXX_DiscardUnknown()
func (*LoginRequest) XXX_Marshal ¶
func (m *LoginRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*LoginRequest) XXX_Merge ¶
func (m *LoginRequest) XXX_Merge(src proto.Message)
func (*LoginRequest) XXX_Size ¶
func (m *LoginRequest) XXX_Size() int
func (*LoginRequest) XXX_Unmarshal ¶
func (m *LoginRequest) XXX_Unmarshal(b []byte) error
type MessageReceiver ¶
type MessageReceiver struct {
Seq int32
// contains filtered or unexported fields
}
func (*MessageReceiver) DeleteSeq ¶
func (r *MessageReceiver) DeleteSeq(seq int32)
func (*MessageReceiver) PrepareRequest ¶
func (r *MessageReceiver) PrepareRequest() (int32, <-chan interface{})
func (*MessageReceiver) SendResponse ¶
func (r *MessageReceiver) SendResponse(seq int32, msg interface{}) error
type RpcHeader ¶
type RpcHeader struct {
Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
Seq int32 `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func NewResponseHeader ¶
func (*RpcHeader) Descriptor ¶
func (*RpcHeader) ProtoMessage ¶
func (*RpcHeader) ProtoMessage()
func (*RpcHeader) XXX_DiscardUnknown ¶
func (m *RpcHeader) XXX_DiscardUnknown()
func (*RpcHeader) XXX_Marshal ¶
func (*RpcHeader) XXX_Unmarshal ¶
type RpcMessage ¶
Click to show internal directories.
Click to hide internal directories.