highway

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 21 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 BaseClient added in v0.7.1

type BaseClient struct {
	// contains filtered or unexported fields
}

BaseClient highway base client

func (*BaseClient) AddWaitMsg added in v0.7.1

func (baseClient *BaseClient) AddWaitMsg(msgID uint64, result *InvocationContext)

AddWaitMsg add wait msg

func (*BaseClient) Close added in v0.7.1

func (baseClient *BaseClient) Close()

Close client

func (*BaseClient) Closed added in v0.7.1

func (baseClient *BaseClient) Closed() bool

Closed client status

func (*BaseClient) GetAddr added in v0.7.1

func (baseClient *BaseClient) GetAddr() string

GetAddr Obtain the address

func (*BaseClient) GetWaitMsg added in v0.7.1

func (baseClient *BaseClient) GetWaitMsg(msgID uint64) *InvocationContext

GetWaitMsg get wait message

func (*BaseClient) Open added in v0.7.1

func (baseClient *BaseClient) Open() error

Open client

func (*BaseClient) RemoveWaitMsg added in v0.7.1

func (baseClient *BaseClient) RemoveWaitMsg(msgID uint64)

RemoveWaitMsg remove wait msg

func (*BaseClient) Send added in v0.7.1

func (baseClient *BaseClient) Send(req *Request, rsp *Response, timeout time.Duration) error

Send send msg

type ClientConnection added in v0.7.1

type ClientConnection struct {
	// contains filtered or unexported fields
}

ClientConnection Highway client connection

func NewHighwayClientConnection

func NewHighwayClientConnection(conn net.Conn, client *BaseClient) *ClientConnection

NewHighwayClientConnection creat Highway client connection

func (*ClientConnection) AsyncSendMsg added in v0.7.1

func (hwClientConn *ClientConnection) AsyncSendMsg(ctx *InvocationContext) error

AsyncSendMsg Highway send message

func (*ClientConnection) Close added in v0.7.1

func (hwClientConn *ClientConnection) Close()

Close the connection

func (*ClientConnection) Closed added in v0.7.1

func (hwClientConn *ClientConnection) Closed() bool

Closed Highway connection status

func (*ClientConnection) Hello added in v0.7.1

func (hwClientConn *ClientConnection) Hello() error

Hello Highway handshake

func (*ClientConnection) Open added in v0.7.1

func (hwClientConn *ClientConnection) Open() error

Open Init Highway client connection

func (*ClientConnection) PostMsg added in v0.7.1

func (hwClientConn *ClientConnection) PostMsg(req *Request) error

PostMsg Highway post message, Respond is needless

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) (*BaseClient, error)

GetClient Obtain client

type ConnParams

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

ConnParams highway connect parmas

type InvocationContext

type InvocationContext struct {
	Req  *Request
	Rsp  *Response
	Wait *chan int
	// contains filtered or unexported fields
}

InvocationContext Highway context

func (*InvocationContext) Done

func (ctx *InvocationContext) Done()

Done Notify done.

type ProtocolObject added in v0.7.1

type ProtocolObject struct {
	FrHead highwayFrameHead
	// contains filtered or unexported fields
}

ProtocolObject highway Protocal

func (*ProtocolObject) DeSerializeFrame added in v0.7.1

func (msgObj *ProtocolObject) DeSerializeFrame(rdBuf *bufio.Reader) error

DeSerializeFrame Deserialize frame

func (*ProtocolObject) DeSerializeReq added in v0.7.1

func (msgObj *ProtocolObject) DeSerializeReq(req *Request) error

DeSerializeReq Deserialize req

func (*ProtocolObject) DeSerializeRsp added in v0.7.1

func (msgObj *ProtocolObject) DeSerializeRsp(rsp *Response) error

DeSerializeRsp Deserialize rsp

func (*ProtocolObject) ProtocolName added in v0.7.1

func (msgObj *ProtocolObject) ProtocolName() string

ProtocolName protocal name

func (*ProtocolObject) SerializeHelloReq added in v0.7.1

func (msgObj *ProtocolObject) SerializeHelloReq(wBuf *bufio.Writer) error

SerializeHelloReq Serialize hello req

func (*ProtocolObject) SerializeLoginRap added in v0.7.1

func (msgObj *ProtocolObject) SerializeLoginRap(msgID uint64, wBuf *bufio.Writer) error

SerializeLoginRap Serialize hello req

func (*ProtocolObject) SerializeReq added in v0.7.1

func (msgObj *ProtocolObject) SerializeReq(req *Request, wBuf *bufio.Writer)

SerializeReq Serialize request

func (*ProtocolObject) SerializeRsp added in v0.7.1

func (msgObj *ProtocolObject) SerializeRsp(rsp *Response, wBuf *bufio.Writer)

SerializeRsp Serialize frame

type Request added in v0.7.1

type Request struct {
	MsgID       uint64
	MsgType     int
	TwoWay      bool
	Arg         interface{}
	MethodName  string
	SvcName     string
	Schema      string
	Attachments map[string]string
}

Request Highway request

type Response added in v0.7.1

type Response struct {
	MsgID       uint64
	Status      int
	Err         string
	MsgType     int
	Result      interface{}
	Attachments map[string]string
}

Response Highway response

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