transport

package
v0.0.0-...-f1b2c4c Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PKG_LESS = iota
	PKG_FULL
	PKG_ERR
)

Variables

This section is empty.

Functions

func ParsePkg

func ParsePkg(req []byte) (pkgLen, status int)

Types

type CltProtocol

type CltProtocol interface {
	Send(reqId int32, servant, funcName string, pkg []byte) ([]byte, error)
	Recv(pkg []byte)
	ParsePkg(pkg []byte) (int, int)
	String() string
}

type GPool

type GPool interface {
	Start()
	AddTask(t func())
	Release()
}

type Logger

type Logger interface {
	Debug(msg ...interface{})
	Info(msg ...interface{})
	Warn(msg ...interface{})
	Error(msg ...interface{})

	Debugf(tpl string, args ...interface{})
	Infof(tpl string, args ...interface{})
	Warnf(tpl string, args ...interface{})
	Errorf(tpl string, args ...interface{})
}
var OLOG Logger

type OneClt

type OneClt struct {
	Proto CltProtocol
	// contains filtered or unexported fields
}

func NewOneClt

func NewOneClt(cp CltProtocol, logger Logger, conf *OneCltConf) *OneClt

func (*OneClt) GetConf

func (c *OneClt) GetConf() *OneCltConf

func (*OneClt) Send

func (c *OneClt) Send(pkg []byte) (err error)

type OneCltConf

type OneCltConf struct {
	Address       string
	Balance       string `yaml:"balance"`
	TransProtocol string `yaml:"trans_protocol"`

	QueueCap int `yaml:"queue_cap"`

	DialTimeout  time.Duration `yaml:"dial_timeout"`
	ReadTimeout  time.Duration `yaml:"read_timeout"`
	WriteTimeout time.Duration `yaml:"write_timeout"`
	IdleTimeout  time.Duration `yaml:"idle_timeout"`
}

type OneHandler

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

type OneSvr

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

func NewOneSvr

func NewOneSvr(sp SvrProtocol, logger Logger, conf *OneSvrConf) *OneSvr

func (*OneSvr) GetConf

func (s *OneSvr) GetConf() *OneSvrConf

func (*OneSvr) Serve

func (s *OneSvr) Serve() (err error)

func (*OneSvr) Shutdown

func (s *OneSvr) Shutdown()

type OneSvrConf

type OneSvrConf struct {
	Address  string `yaml:"address"`
	Protocol string `yaml:"protocol"`

	MaxInvoke int `yaml:"max_invoke"`
	QueueCap  int `yaml:"queue_cap"`

	AcceptTimeout time.Duration `yaml:"accept_timeout"`
	ReadTimeout   time.Duration
	WriteTimeout  time.Duration
	HandleTimeout time.Duration
	IdleTimeout   time.Duration

	TCPReadBuf  int
	TCPWriteBuf int
	TCPNoDelay  bool

	ServiceWeight int `yaml:"service_weight"`
}

type SvrProtocol

type SvrProtocol interface {
	Invoke(ctx context.Context, req []byte) []byte
	ParsePkg(pkg []byte) (int, int)
	InvokeTimeout(ctx context.Context, req []byte) []byte
}

Jump to

Keyboard shortcuts

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