utils

package
v2.3.0-beta29 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package utils provides utility functions for MySQL packets

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToMySQLPacket

func BytesToMySQLPacket(buffer []byte) (mysql.Packet, error)

BytesToMySQLPacket converts a byte slice to a MySQL packet

func GetPayloadLength

func GetPayloadLength(src []byte) (length uint32)

GetPayloadLength returns the length of the payload from the first 3 bytes of the packet.

func IsEOFPacket

func IsEOFPacket(data []byte) bool

func IsERRPacket

func IsERRPacket(data []byte) bool

func IsGenericResponse

func IsGenericResponse(data []byte) (string, bool)

func IsOKPacket

func IsOKPacket(data []byte) bool

func ReadFirstBuffer

func ReadFirstBuffer(ctx context.Context, logger *zap.Logger, clientConn, destConn net.Conn) ([]byte, string, error)

ReadFirstBuffer reads the first buffer from either clientConn or destConn

func ReadLengthEncodedInteger

func ReadLengthEncodedInteger(b []byte) (num uint64, isNull bool, n int)

func ReadLengthEncodedString

func ReadLengthEncodedString(b []byte) ([]byte, bool, int, error)

func ReadNullTerminatedString

func ReadNullTerminatedString(b []byte) ([]byte, int, error)

ReadNullTerminatedString reads a null-terminated string from a byte slice

func ReadPacketBuffer

func ReadPacketBuffer(ctx context.Context, logger *zap.Logger, conn net.Conn) ([]byte, error)

ReadPacketBuffer reads a MySQL packet from the connection

func ReadPacketStream

func ReadPacketStream(ctx context.Context, logger *zap.Logger, conn net.Conn, bufferChannel chan []byte, errChannel chan error)

ReadPacketStream reads packets from the connection and sends them to the bufferChannel

func ReadUint24

func ReadUint24(b []byte) uint32

func WriteLengthEncodedInteger

func WriteLengthEncodedInteger(buf *bytes.Buffer, num uint64) error

func WriteLengthEncodedString

func WriteLengthEncodedString(buf *bytes.Buffer, s string) error

func WriteStream

func WriteStream(ctx context.Context, logger *zap.Logger, conn net.Conn, buff [][]byte) error

func WriteUint24

func WriteUint24(buf *bytes.Buffer, value uint32) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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