transport

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: BSD-3-Clause Imports: 19 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// PackageLess shows is not a completed package.
	PackageLess = iota
	// PackageFull shows is a completed package.
	PackageFull
	// PackageError shows is a error package.
	PackageError
)

Variables

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

TLOG is logger for transport.

Functions

This section is empty.

Types

type ClientProtocol added in v1.1.2

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

ClientProtocol interface for handling tars client package.

type ServerHandler

type ServerHandler interface {
	Listen() error
	Handle() error
	OnShutdown()
	CloseIdles(n int64) bool
}

ServerHandler is interface with listen and handler method

type ServerProtocol added in v1.1.2

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

ServerProtocol is interface for handling the server side tars package.

type TarsClient

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

TarsClient is struct for tars client.

func NewTarsClient

func NewTarsClient(address string, protocol ClientProtocol, config *TarsClientConf) *TarsClient

NewTarsClient new tars client and init it .

func (*TarsClient) Close

func (tc *TarsClient) Close()

Close the client connection with the server.

func (*TarsClient) GraceClose

func (tc *TarsClient) GraceClose(ctx context.Context)

GraceClose close client gracefully

func (*TarsClient) ReConnect added in v1.1.2

func (tc *TarsClient) ReConnect() error

ReConnect established 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  ClientProtocol
	QueueLen     int
	IdleTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	DialTimeout  time.Duration
	TlsConfig    *tls.Config
}

TarsClientConf is tars client side config

type TarsServer

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

TarsServer tars server struct.

func NewTarsServer

func NewTarsServer(protocol ServerProtocol, config *TarsServerConf) *TarsServer

NewTarsServer new TarsServer and init with config.

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

func (ts *TarsServer) Listen() error

Listen listens on the network address

func (*TarsServer) Serve

func (ts *TarsServer) Serve() error

Serve accepts incoming connections

func (*TarsServer) Shutdown

func (ts *TarsServer) Shutdown(ctx context.Context) error

Shutdown try to shutdown server gracefully.

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
	TlsConfig      *tls.Config
}

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