conn

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBackendConn

func NewBackendConn(lg *zap.Logger, connID uint64, hsHandler backend.HandshakeHandler, bcConfig *backend.BCConfig,
	backendTLSConfig *tls.Config, username, password string) *backendConn

func NewConn

func NewConn(lg *zap.Logger, username, password string, backendTLSConfig *tls.Config, hsHandler backend.HandshakeHandler,
	idMgr *id.IDManager, connID uint64, bcConfig *backend.BCConfig, exceptionCh chan<- Exception, closeCh chan<- uint64, replayStats *ReplayStats) *conn

Types

type BackendConn

type BackendConn interface {
	Connect(ctx context.Context) error
	ConnID() uint64
	ExecuteCmd(ctx context.Context, request []byte) error
	Query(ctx context.Context, stmt string) error
	PrepareStmt(ctx context.Context, stmt string) (stmtID uint32, err error)
	ExecuteStmt(ctx context.Context, stmtID uint32, args []any) error
	GetPreparedStmt(stmtID uint32) (text string, paramNum int, paramTypes []byte)
	Close()
}

type BackendConnManager

type BackendConnManager interface {
	Connect(ctx context.Context, clientIO pnet.PacketIO, frontendTLSConfig, backendTLSConfig *tls.Config, username, password string) error
	ExecuteCmd(ctx context.Context, request []byte) error
	ConnectionID() uint64
	Close() error
}

type Conn

type Conn interface {
	Run(ctx context.Context)
	ExecuteCmd(command *cmd.Command)
	Stop()
}

type ConnCreator

type ConnCreator func(connID uint64) Conn

type Exception

type Exception interface {
	Type() ExceptionType
	Key() string
	ConnID() uint64
	Time() time.Time
}

type ExceptionType

type ExceptionType int
const (
	// connect error, handshake error
	Other ExceptionType = iota
	// execute error
	Fail
	// the error type count
	Total
)

func (ExceptionType) String

func (t ExceptionType) String() string

type FailException

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

func NewFailException

func NewFailException(err error, command *cmd.Command) *FailException

func (*FailException) Command

func (fe *FailException) Command() *cmd.Command

func (*FailException) ConnID

func (fe *FailException) ConnID() uint64

func (*FailException) Error

func (fe *FailException) Error() string

func (*FailException) Key

func (fe *FailException) Key() string

func (*FailException) Time

func (fe *FailException) Time() time.Time

func (*FailException) Type

func (fe *FailException) Type() ExceptionType

type OtherException

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

func NewOtherException

func NewOtherException(err error, connID uint64) *OtherException

func (*OtherException) ConnID

func (oe *OtherException) ConnID() uint64

func (*OtherException) Error

func (oe *OtherException) Error() string

func (*OtherException) Key

func (oe *OtherException) Key() string

func (*OtherException) Time

func (oe *OtherException) Time() time.Time

func (*OtherException) Type

func (oe *OtherException) Type() ExceptionType

type ReplayStats

type ReplayStats struct {
	// ReplayedCmds is the number of executed commands.
	ReplayedCmds atomic.Uint64
	// PendingCmds is the number of decoded but not executed commands.
	PendingCmds atomic.Int64
}

ReplayStats record the statistics during replay. All connections share one ReplayStats and update it concurrently.

func (*ReplayStats) Reset

func (s *ReplayStats) Reset()

Jump to

Keyboard shortcuts

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