Documentation
¶
Index ¶
- Constants
- type Conn
- func NewBufferedConn(conn net.Conn, bufferSize int) *Conn
- func NewConn(conn net.Conn) *Conn
- func NewConnWithTimeout(conn net.Conn, readTimeout, writeTimeout time.Duration, bufferSize int) *Conn
- func NewTLSConn(conn net.Conn) *Conn
- func NewTLSConnWithTimeout(conn net.Conn, readTimeout, writeTimeout time.Duration) *Conn
- func (c *Conn) Close() error
- func (c *Conn) EnableReadBuffering(bufferSize int)
- func (c *Conn) EnableWriteBuffering(bufferSize int)
- func (c *Conn) Flush() error
- func (c *Conn) ReadPacket() ([]byte, error)
- func (c *Conn) ReadPacketReuseMem(dst []byte) ([]byte, error)
- func (c *Conn) ReadPacketTo(w io.Writer) error
- func (c *Conn) ResetSequence()
- func (c *Conn) WriteAuthSwitchPacket(authData []byte, addNUL bool) error
- func (c *Conn) WriteClearAuthPacket(password string) error
- func (c *Conn) WriteEncryptedPassword(password string, seed []byte, pub *rsa.PublicKey) error
- func (c *Conn) WritePacket(data []byte) error
- func (c *Conn) WritePublicKeyAuthPacket(password string, cipher []byte) error
Constants ¶
const ( MinCompressionLength = 50 DefaultBufferSize = 16 * 1024 // DefaultReadBufferSize is the bufio.Reader size used by NewConn and // EnableReadBuffering. DefaultReadBufferSize = 64 * 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
net.Conn
Sequence uint8
Compression uint8
CompressedSequence uint8
// contains filtered or unexported fields
}
Conn is the base class to handle MySQL protocol.
func NewConnWithTimeout ¶
func NewTLSConn ¶
func NewTLSConnWithTimeout ¶
func (*Conn) EnableReadBuffering ¶
EnableReadBuffering wraps subsequent reads in a bufio.Reader of the given size. Conns created via NewTLSConn start unbuffered because the peer may still upgrade the transport to TLS during the handshake; call this once the handshake completes, and only between packets. No-op if reads are already buffered or bufferSize is not positive.
func (*Conn) EnableWriteBuffering ¶
EnableWriteBuffering makes WritePacket accumulate packets in a buffer of the given size instead of issuing one write(2) each. Buffered data reaches the wire when the buffer fills, on Flush, or before any ReadPacket* call (so request/response flows cannot deadlock). Callers that stream packets without reading must Flush after each logical unit; Close does not flush. No-op if already enabled or bufferSize is not positive.
func (*Conn) Flush ¶
Flush writes any buffered packets to the underlying connection. It is a no-op when write buffering is not enabled.
func (*Conn) ReadPacket ¶
func (*Conn) ResetSequence ¶
func (c *Conn) ResetSequence()
func (*Conn) WriteAuthSwitchPacket ¶
WriteAuthSwitchPacket see https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_auth_switch_response.html
func (*Conn) WriteClearAuthPacket ¶
WriteClearAuthPacket Client clear text authentication packet https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_auth_switch_response.html
func (*Conn) WriteEncryptedPassword ¶
func (*Conn) WritePacket ¶
WritePacket data already has 4 bytes header will modify data in-place
func (*Conn) WritePublicKeyAuthPacket ¶
WritePublicKeyAuthPacket Caching sha2 authentication. Public key request and send encrypted password https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_auth_switch_response.html