multiplexed

package
v0.0.0-...-115e584 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Initial 初始状态
	Initial int = iota
	// Connected 已连接
	Connected
	// ReConnecting 重连中
	ReConnecting
	// Closing 关闭中
	Closing
	// Closed 连接已关闭
	Closed
)

Variables

View Source
var (
	// ErrConnClosed 连接已关闭
	ErrConnClosed = errors.New("connection is closed")
	// ErrFramBuilderNil framer builder 没有设置
	ErrFrameBuilderNil = errors.New("framer builder is nil")
	// ErrDecoderNil 没有实现Decoder
	ErrDecoderNil = errors.New("framer do not implement Decoder interface")
	// ErrQueueFull 队列满了
	ErrQueueFull = errors.New("connection queue is full")
	// ErrChanClose 连接关闭
	ErrChanClose = errors.New("unexpected recv chan close")
	// ErrWriteBufferDone 写buffer已经关闭
	ErrWriteBufferDone = errors.New("write buffer done")
	// ErrAssertFail 断言类型错误
	ErrAssertFail = errors.New("assert connection slice fail")
	// ErrNoConnection 没有可用连接
	ErrNoConnection = errors.New("no connection is available")
	// ErrVirtualConnectionClose 连接关闭
	ErrVirtualConnectionClose = errors.New("VirtualConnection has already Closed")
)
View Source
var DefaultMultiplexedPool = New()

DefaultMultiplexedPool 默认的多路复用实现

Functions

This section is empty.

Types

type Connection

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

type Connections

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

type GetOption

type GetOption func(*GetOptions)

func WithDialTLS

func WithDialTLS(certFile, keyFile, caFile, serverName string) GetOption

func WithFramerBuilder

func WithFramerBuilder(fb conn.FramerBuilder) GetOption

func WithMsg

func WithMsg(msg conn.Msg) GetOption

type GetOptions

type GetOptions struct {
	FramerBuilder conn.FramerBuilder
	Msg           conn.Msg

	CACertFile    string
	TLSCertFile   string
	TLSKeyFile    string
	TLSServerName string
}

GetOptions get conn configuration

type Multiplexed

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

func New

func New(opt ...PoolOption) *Multiplexed

func (*Multiplexed) Get

func (p *Multiplexed) Get(ctx context.Context, network string,
	address string, opt ...GetOption) (*VirtualConnection, error)

Get 获取多路复用对应的虚拟连接

type PoolOption

type PoolOption func(*PoolOptions)

PoolOption Options heler

func WithConnectNumber

func WithConnectNumber(number int) PoolOption

func WithDropFull

func WithDropFull(drop bool) PoolOption

func WithQueueSize

func WithQueueSize(number int) PoolOption

type PoolOptions

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

PoolOptions 连接池的一些设置

type VirtualConnection

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

VirtualConnection 多路复用虚拟连接

func (*VirtualConnection) Read

func (vc *VirtualConnection) Read() ([]byte, error)

Read 获取回包

func (*VirtualConnection) Write

func (vc *VirtualConnection) Write(b []byte) error

Write 写入请求包

Jump to

Keyboard shortcuts

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