transport

package
v0.0.0-...-2e3adde Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//PACKAGE_LESS shows is not a completed package.
	PACKAGE_LESS = iota
	//PACKAGE_FULL shows is a completed package.
	PACKAGE_FULL
	//PACKAGE_ERROR shows is a error package.
	PACKAGE_ERROR
)

Variables

View Source
var TLOG = rogger.GetLogger("TLOG")

TLOG is logger for transport.

Functions

This section is empty.

Types

type ServerHandler

type ServerHandler interface {
	Listen() error
	Handle() error
}

ServerHandler is interface with listen and handler method

type TarsClient

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

TarsClient is struct for tars client.

func NewTarsClient

func NewTarsClient(address string, cp TarsClientProtocol, conf *TarsClientConf) *TarsClient

NewTarsClient new tars client and init it .

func (*TarsClient) Close

func (tc *TarsClient) Close()

Close close the client connection with the server.

func (*TarsClient) Send

func (tc *TarsClient) Send(req []byte) error

Send sends the request to the server as []byte.

type TarsClientConf

type TarsClientConf struct {
	Proto        string
	ClientProto  TarsClientProtocol
	QueueLen     int
	IdleTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

TarsClientConf is tars client side config

type TarsClientProtocol

type TarsClientProtocol interface {
	Recv(pkg []byte)
	ParsePackage(buff []byte) (int, int)
}

TarsClientProtocol interface for handling tars client package.

type TarsProtoCol

type TarsProtoCol interface {
	Invoke(ctx context.Context, pkg []byte) []byte
	ParsePackage(buff []byte) (int, int)
	InvokeTimeout(pkg []byte) []byte
}

TarsProtoCol is interface for handling the server side tars package.

type TarsServer

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

TarsServer tars server struct.

func NewTarsServer

func NewTarsServer(svr TarsProtoCol, conf *TarsServerConf) *TarsServer

NewTarsServer new TarsServer and init with conf.

func (*TarsServer) GetConfig

func (ts *TarsServer) GetConfig() *TarsServerConf

GetConfig gets the tars server config.

func (*TarsServer) IsZombie

func (ts *TarsServer) IsZombie(timeout time.Duration) bool

IsZombie show whether the server is hanged by the request.

func (*TarsServer) Serve

func (ts *TarsServer) Serve() error

Serve listen and handle

func (*TarsServer) Shutdown

func (ts *TarsServer) Shutdown()

Shutdown shutdown the server.

type TarsServerConf

type TarsServerConf struct {
	Proto          string
	Address        string
	MaxInvoke      int32
	AcceptTimeout  time.Duration
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
	HandleTimeout  time.Duration
	IdleTimeout    time.Duration
	QueueCap       int
	TCPReadBuffer  int
	TCPWriteBuffer int
	TCPNoDelay     bool
}

TarsServerConf server config for tars server side.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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