highway

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReadBufferSize  = 0
	DefaultWriteBufferSize = 1024
)

constant for buffer size

View Source
const (
	//Name is a variable of type string
	Name                  = "highway"
	DefaultConnectTimeOut = 60
	DefaultSendTimeOut    = 300
)

const timeout

View Source
const (
	FrameHeadLen = 23
	MagicLen     = 7
)

number const

View Source
const (
	Ok          = 200
	ServerError = 505
)

status code

Variables

This section is empty.

Functions

func GenerateMsgID

func GenerateMsgID() uint64

GenerateMsgID generate message ID

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

type ConnParams struct {
	Addr      string
	TLSConfig *tls.Config
	Timeout   time.Duration
	ConnNum   int
}

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) Close

func (baseClient *HighwayBaseClient) Close()

Close client

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) Open

func (baseClient *HighwayBaseClient) Open() error

Open client

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

func (*InvocationContext) Done

func (ctx *InvocationContext) Done()

Done Notify done.

Directories

Path Synopsis
Package highway is a generated protocol buffer package.
Package highway is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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