highway

package
v0.0.0-...-d164338 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 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, error)

NewHighwayClient is a function Deprecated

Types

type BaseClient

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

BaseClient highway base client

func (*BaseClient) AddWaitMsg

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

AddWaitMsg add wait msg

func (*BaseClient) Close

func (baseClient *BaseClient) Close()

Close client

func (*BaseClient) Closed

func (baseClient *BaseClient) Closed() bool

Closed client status

func (*BaseClient) GetAddr

func (baseClient *BaseClient) GetAddr() string

GetAddr Obtain the address

func (*BaseClient) GetWaitMsg

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

GetWaitMsg get wait message

func (*BaseClient) Open

func (baseClient *BaseClient) Open() error

Open client

func (*BaseClient) RemoveWaitMsg

func (baseClient *BaseClient) RemoveWaitMsg(msgID uint64)

RemoveWaitMsg remove wait msg

func (*BaseClient) Send

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

Send send msg

type ClientConnection

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

ClientConnection Highway client connection Deprecated

func NewHighwayClientConnection

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

NewHighwayClientConnection creat Highway client connection Deprecated

func (*ClientConnection) AsyncSendMsg

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

AsyncSendMsg Highway send message

func (*ClientConnection) Close

func (hwClientConn *ClientConnection) Close()

Close the connection

func (*ClientConnection) Closed

func (hwClientConn *ClientConnection) Closed() bool

Closed Highway connection status

func (*ClientConnection) Hello

func (hwClientConn *ClientConnection) Hello() error

Hello Highway handshake

func (*ClientConnection) Open

func (hwClientConn *ClientConnection) Open() error

Open Init Highway client connection

func (*ClientConnection) PostMsg

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

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

ProtocolObject highway Protocal

func (*ProtocolObject) DeSerializeFrame

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

DeSerializeFrame Deserialize frame

func (*ProtocolObject) DeSerializeReq

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

DeSerializeReq Deserialize req

func (*ProtocolObject) DeSerializeRsp

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

DeSerializeRsp Deserialize rsp

func (*ProtocolObject) ProtocolName

func (msgObj *ProtocolObject) ProtocolName() string

ProtocolName protocal name

func (*ProtocolObject) SerializeHelloReq

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

SerializeHelloReq Serialize hello req

func (*ProtocolObject) SerializeLoginRap

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

SerializeLoginRap Serialize hello req

func (*ProtocolObject) SerializeReq

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

SerializeReq Serialize request

func (*ProtocolObject) SerializeRsp

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

SerializeRsp Serialize frame

type Request

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

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