Documentation ¶
Index ¶
- Constants
- func GenerateMsgID() uint64
- func NewHighwayClient(options client.Options) client.ProtocolClient
- type ClientMgr
- type ConnParams
- type HighWayProtocalObject
- func (msgObj *HighWayProtocalObject) DeSerializeFrame(rdBuf *bufio.Reader) error
- func (msgObj *HighWayProtocalObject) DeSerializeReq(req *HighwayRequest) error
- func (msgObj *HighWayProtocalObject) DeSerializeRsp(rsp *HighwayRespond) error
- func (msgObj *HighWayProtocalObject) ProtocalName() string
- func (msgObj *HighWayProtocalObject) SerializeHelloReq(wBuf *bufio.Writer) error
- func (msgObj *HighWayProtocalObject) SerializeReq(req *HighwayRequest, wBuf *bufio.Writer)
- func (msgObj *HighWayProtocalObject) SerializeRsp(rsp *HighwayRespond, wBuf *bufio.Writer)
- func (msgObj *HighWayProtocalObject) SerializelLoginRsp(msgID uint64, wBuf *bufio.Writer) error
- type HighwayBaseClient
- func (baseClient *HighwayBaseClient) AddWaitMsg(msgID uint64, result *InvocationContext)
- func (baseClient *HighwayBaseClient) Close()
- func (baseClient *HighwayBaseClient) Closed() bool
- func (baseClient *HighwayBaseClient) GetAddr() string
- func (baseClient *HighwayBaseClient) GetWaitMsg(msgID uint64) *InvocationContext
- func (baseClient *HighwayBaseClient) Open() error
- func (baseClient *HighwayBaseClient) RemoveWaitMsg(msgID uint64)
- func (baseClient *HighwayBaseClient) Send(req *HighwayRequest, rsp *HighwayRespond, timeout time.Duration) error
- type HighwayClientConnection
- func (hwClientConn *HighwayClientConnection) AsyncSendMsg(ctx *InvocationContext) error
- func (hwClientConn *HighwayClientConnection) Close()
- func (hwClientConn *HighwayClientConnection) Closed() bool
- func (hwClientConn *HighwayClientConnection) Hello() error
- func (hwClientConn *HighwayClientConnection) Open() error
- func (hwClientConn *HighwayClientConnection) PostMsg(req *HighwayRequest) error
- type HighwayRequest
- type HighwayRespond
- type InvocationContext
Constants ¶
const ( DefaultReadBufferSize = 0 DefaultWriteBufferSize = 1024 )
constant for buffer size
const ( //Name is a variable of type string Name = "highway" DefaultConnectTimeOut = 60 DefaultSendTimeOut = 300 )
const timeout
const ( FrameHeadLen = 23 MagicLen = 7 )
number const
const ( Ok = 200 ServerError = 505 )
status code
Variables ¶
This section is empty.
Functions ¶
func NewHighwayClient ¶
func NewHighwayClient(options client.Options) client.ProtocolClient
NewHighwayClient is a function
Types ¶
type ClientMgr ¶
type ClientMgr struct {
// contains filtered or unexported fields
}
ClientMgr client manage
var CachedClients *ClientMgr
CachedClients client cache
func (*ClientMgr) GetClient ¶
func (mgr *ClientMgr) GetClient(connParmas *ConnParams) (*HighwayBaseClient, error)
GetClient Obtain client
type ConnParams ¶
ConnParams highway connect parmas
type HighWayProtocalObject ¶
type HighWayProtocalObject struct { FrHead highwayFrameHead // contains filtered or unexported fields }
HighWayProtocalObject highway Protocal
func (*HighWayProtocalObject) DeSerializeFrame ¶
func (msgObj *HighWayProtocalObject) DeSerializeFrame(rdBuf *bufio.Reader) error
DeSerializeFrame Deserialize frame
func (*HighWayProtocalObject) DeSerializeReq ¶
func (msgObj *HighWayProtocalObject) DeSerializeReq(req *HighwayRequest) error
DeSerializeReq Deserialize req
func (*HighWayProtocalObject) DeSerializeRsp ¶
func (msgObj *HighWayProtocalObject) DeSerializeRsp(rsp *HighwayRespond) error
DeSerializeRsp Deserialize rsp
func (*HighWayProtocalObject) ProtocalName ¶
func (msgObj *HighWayProtocalObject) ProtocalName() string
ProtocalName protocal name
func (*HighWayProtocalObject) SerializeHelloReq ¶
func (msgObj *HighWayProtocalObject) SerializeHelloReq(wBuf *bufio.Writer) error
SerializeHelloReq Serialize hello req
func (*HighWayProtocalObject) SerializeReq ¶
func (msgObj *HighWayProtocalObject) SerializeReq(req *HighwayRequest, wBuf *bufio.Writer)
SerializeReq Serialize request
func (*HighWayProtocalObject) SerializeRsp ¶
func (msgObj *HighWayProtocalObject) SerializeRsp(rsp *HighwayRespond, wBuf *bufio.Writer)
SerializeRsp Serialize frame
func (*HighWayProtocalObject) SerializelLoginRsp ¶
func (msgObj *HighWayProtocalObject) SerializelLoginRsp(msgID uint64, wBuf *bufio.Writer) error
SerializelLoginRsp Serialize hello req
type HighwayBaseClient ¶
type HighwayBaseClient struct {
// contains filtered or unexported fields
}
HighwayBaseClient highway base client
func (*HighwayBaseClient) AddWaitMsg ¶
func (baseClient *HighwayBaseClient) AddWaitMsg(msgID uint64, result *InvocationContext)
AddWaitMsg add wait msg
func (*HighwayBaseClient) Closed ¶
func (baseClient *HighwayBaseClient) Closed() bool
Closed client status
func (*HighwayBaseClient) GetAddr ¶
func (baseClient *HighwayBaseClient) GetAddr() string
GetAddr Obtain the address
func (*HighwayBaseClient) GetWaitMsg ¶
func (baseClient *HighwayBaseClient) GetWaitMsg(msgID uint64) *InvocationContext
GetWaitMsg get wait message
func (*HighwayBaseClient) RemoveWaitMsg ¶
func (baseClient *HighwayBaseClient) RemoveWaitMsg(msgID uint64)
RemoveWaitMsg remove wait msg
func (*HighwayBaseClient) Send ¶
func (baseClient *HighwayBaseClient) Send(req *HighwayRequest, rsp *HighwayRespond, timeout time.Duration) error
Send send msg
type HighwayClientConnection ¶
type HighwayClientConnection struct {
// contains filtered or unexported fields
}
HighwayClientConnection Highway client connection
func NewHighwayClientConnection ¶
func NewHighwayClientConnection(conn net.Conn, client *HighwayBaseClient) *HighwayClientConnection
NewHighwayClientConnection creat Highway client connection
func (*HighwayClientConnection) AsyncSendMsg ¶
func (hwClientConn *HighwayClientConnection) AsyncSendMsg(ctx *InvocationContext) error
AsyncSendMsg Highway send message
func (*HighwayClientConnection) Close ¶
func (hwClientConn *HighwayClientConnection) Close()
Close the connection
func (*HighwayClientConnection) Closed ¶
func (hwClientConn *HighwayClientConnection) Closed() bool
Closed Highway connection status
func (*HighwayClientConnection) Hello ¶
func (hwClientConn *HighwayClientConnection) Hello() error
Hello Highway handshake
func (*HighwayClientConnection) Open ¶
func (hwClientConn *HighwayClientConnection) Open() error
Open Init Highway client connection
func (*HighwayClientConnection) PostMsg ¶
func (hwClientConn *HighwayClientConnection) PostMsg(req *HighwayRequest) error
PostMsg Highway post message, Respond is needless
type HighwayRequest ¶
type HighwayRequest struct { MsgID uint64 MsgType int TwoWay bool Arg interface{} MethodName string SvcName string Schema string Attachments map[string]string }
HighwayRequest Highway request
type HighwayRespond ¶
type HighwayRespond struct { MsgID uint64 Status int Err string MsgType int Result interface{} Attachments map[string]string }
HighwayRespond Highway respond
type InvocationContext ¶
type InvocationContext struct { Req *HighwayRequest Rsp *HighwayRespond Wait *chan int }
InvocationContext Highway context