transport

package
v1.3.22 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: BSD-3-Clause Imports: 20 Imported by: 0

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

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

ClientProtocol interface for handling ksf client package.

type KsfClient

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

KsfClient is struct for ksf client.

func NewKsfClient

func NewKsfClient(address string, cp ClientProtocol, conf *KsfClientConf) *KsfClient

NewKsfClient new ksf client and init it .

func (*KsfClient) Close

func (tc *KsfClient) Close()

Close the client connection with the server.

func (*KsfClient) GraceClose

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

GraceClose close client gracefully

func (*KsfClient) ReConnect

func (tc *KsfClient) ReConnect() error

ReConnect established the client connection with the server.

func (*KsfClient) Send

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

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

type KsfClientConf

type KsfClientConf struct {
	Proto        string
	ClientProto  ClientProtocol
	QueueLen     int
	IdleTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	DialTimeout  time.Duration
	TlsConfig    *tls.Config
}

KsfClientConf is ksf client side config

type KsfServer

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

KsfServer ksf server struct.

func NewKsfServer

func NewKsfServer(svr ServerProtocol, conf *KsfServerConf) *KsfServer

NewKsfServer new KsfServer and init with conf.

func (*KsfServer) GetConfig

func (ts *KsfServer) GetConfig() *KsfServerConf

GetConfig gets the ksf server config.

func (*KsfServer) IsZombie

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

IsZombie show whether the server is hanged by the request.

func (*KsfServer) Listen

func (ts *KsfServer) Listen() error

Listen listens on the network address

func (*KsfServer) Serve

func (ts *KsfServer) Serve() error

Serve accepts incoming connections

func (*KsfServer) Shutdown

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

Shutdown try to shutdown server gracefully.

type KsfServerConf

type KsfServerConf 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
}

KsfServerConf server config for ksf server side.

type ServerHandler

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

ServerHandler is interface with listen and handler method

type ServerProtocol

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 ksf package.

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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