Documentation ¶
Overview ¶
Package multiplexing defines the multiplex connection pool for sending request and receiving response. After receiving the response, the decoded response will be returned to the client. It is used for the communication with TubeMQ.
Index ¶
Constants ¶
const ( Initial int = iota Connected Closing Closed )
The state of the connection.
Variables ¶
var ( // ErrConnClosed indicates the connection has been closed ErrConnClosed = errors.New("connection has been closed") // ErrChanClosed indicates the recv chan has been closed ErrChanClosed = errors.New("unexpected recv chan closing") // ErrWriteBufferDone indicates write buffer done ErrWriteBufferDone = errors.New("write buffer done") // ErrAssertConnection indicates connection assertion error ErrAssertConnection = errors.New("connection assertion error") )
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents the underlying TCP connection of the multiplex connections of an address and maintains the multiplex connections.
type DialOptions ¶
type DialOptions struct { Network string Address string Timeout time.Duration CACertFile string TLSCertFile string TLSKeyFile string TLSServerName string }
DialOptions represents the dail options of the TCP connection. If TLS is not enabled, the configuration of TLS can be ignored.
type MultiplexConnection ¶
type MultiplexConnection struct {
// contains filtered or unexported fields
}
MultiplexConnection is used to multiplex a TCP connection. It is distinguished by the serialNo.
func (*MultiplexConnection) Read ¶
func (mc *MultiplexConnection) Read() (codec.Response, error)
Read returns the response from the multiplex connection.
func (*MultiplexConnection) Write ¶
func (mc *MultiplexConnection) Write(b []byte) error
Write uses the underlying TCP connection to send the bytes.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool maintains the multiplex connections of different addresses.
func (*Pool) Get ¶
func (p *Pool) Get(ctx context.Context, address string, serialNo uint32, opts *DialOptions) (*MultiplexConnection, error)
Get will return a multiplex connection 1. If no underlying TCP connection has been created, a TCP connection will be created first. 2. A new multiplex connection with the serialNo will be created and returned.