stmt

package
v3.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SetTagsMessage = 1
	BindMessage    = 2
)
View Source
const (
	STMTConnect      = "conn"
	STMTInit         = "init"
	STMTPrepare      = "prepare"
	STMTSetTableName = "set_table_name"
	STMTAddBatch     = "add_batch"
	STMTExec         = "exec"
	STMTClose        = "close"
	STMTUseResult    = "use_result"
	WSFetch          = "fetch"
	WSFetchBlock     = "fetch_block"
	WSFreeResult     = "free_result"
)

Variables

View Source
var (
	//revive:disable-next-line
	ConnectTimeoutErr = errors.New("stmt connect timeout")
	ErrConnIsClosed   = errors.New("stmt Connector is closed")
)

Functions

This section is empty.

Types

type AddBatchReq

type AddBatchReq struct {
	ReqID  uint64 `json:"req_id"`
	StmtID uint64 `json:"stmt_id"`
}

type AddBatchResp

type AddBatchResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Action  string `json:"action"`
	ReqID   uint64 `json:"req_id"`
	Timing  int64  `json:"timing"`
	StmtID  uint64 `json:"stmt_id"`
}

type BindReq

type BindReq struct {
	ReqID   uint64          `json:"req_id"`
	StmtID  uint64          `json:"stmt_id"`
	Columns json.RawMessage `json:"columns"`
}

type BindResp

type BindResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Action  string `json:"action"`
	ReqID   uint64 `json:"req_id"`
	Timing  int64  `json:"timing"`
	StmtID  uint64 `json:"stmt_id"`
}

type CloseReq

type CloseReq struct {
	ReqID  uint64 `json:"req_id"`
	StmtID uint64 `json:"stmt_id"`
}

type Config

type Config struct {
	Url                 string
	ChanLength          uint
	MessageTimeout      time.Duration
	WriteWait           time.Duration
	ErrorHandler        func(connector *Connector, err error)
	CloseHandler        func()
	User                string
	Password            string
	DB                  string
	EnableCompression   bool
	AutoReconnect       bool
	ReconnectIntervalMs int
	ReconnectRetryCount int
}

func NewConfig

func NewConfig(url string, chanLength uint) *Config

func (*Config) SetAutoReconnect added in v3.5.6

func (c *Config) SetAutoReconnect(reconnect bool)

func (*Config) SetCloseHandler

func (c *Config) SetCloseHandler(f func())

func (*Config) SetConnectDB

func (c *Config) SetConnectDB(db string) error

func (*Config) SetConnectPass

func (c *Config) SetConnectPass(pass string) error

func (*Config) SetConnectUser

func (c *Config) SetConnectUser(user string) error

func (*Config) SetEnableCompression added in v3.5.2

func (c *Config) SetEnableCompression(enableCompression bool)

func (*Config) SetErrorHandler

func (c *Config) SetErrorHandler(f func(connector *Connector, err error))

func (*Config) SetMessageTimeout

func (c *Config) SetMessageTimeout(timeout time.Duration) error

func (*Config) SetReconnectIntervalMs added in v3.5.6

func (c *Config) SetReconnectIntervalMs(reconnectIntervalMs int)

func (*Config) SetReconnectRetryCount added in v3.5.6

func (c *Config) SetReconnectRetryCount(reconnectRetryCount int)

func (*Config) SetWriteWait

func (c *Config) SetWriteWait(writeWait time.Duration) error

type ConnectReq

type ConnectReq struct {
	ReqID    uint64 `json:"req_id"`
	User     string `json:"user"`
	Password string `json:"password"`
	DB       string `json:"db"`
}

type ConnectResp

type ConnectResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Action  string `json:"action"`
	ReqID   uint64 `json:"req_id"`
	Timing  int64  `json:"timing"`
}

type Connector

type Connector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewConnector

func NewConnector(config *Config) (*Connector, error)

func (*Connector) Close

func (c *Connector) Close() error

func (*Connector) Init

func (c *Connector) Init() (*Stmt, error)

type ExecReq

type ExecReq struct {
	ReqID  uint64 `json:"req_id"`
	StmtID uint64 `json:"stmt_id"`
}

type ExecResp

type ExecResp struct {
	Code     int    `json:"code"`
	Message  string `json:"message"`
	Action   string `json:"action"`
	ReqID    uint64 `json:"req_id"`
	Timing   int64  `json:"timing"`
	StmtID   uint64 `json:"stmt_id"`
	Affected int    `json:"affected"`
}

type IndexedChan

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

type InitReq

type InitReq struct {
	ReqID uint64 `json:"req_id"`
}

type InitResp

type InitResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Action  string `json:"action"`
	ReqID   uint64 `json:"req_id"`
	Timing  int64  `json:"timing"`
	StmtID  uint64 `json:"stmt_id"`
}

type PrepareReq

type PrepareReq struct {
	ReqID  uint64 `json:"req_id"`
	StmtID uint64 `json:"stmt_id"`
	SQL    string `json:"sql"`
}

type PrepareResp

type PrepareResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Action  string `json:"action"`
	ReqID   uint64 `json:"req_id"`
	Timing  int64  `json:"timing"`
	StmtID  uint64 `json:"stmt_id"`
}

type Rows added in v3.5.6

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

func (*Rows) Close added in v3.5.6

func (rs *Rows) Close() error

func (*Rows) ColumnTypeDatabaseTypeName added in v3.5.6

func (rs *Rows) ColumnTypeDatabaseTypeName(i int) string

func (*Rows) ColumnTypeLength added in v3.5.6

func (rs *Rows) ColumnTypeLength(i int) (length int64, ok bool)

func (*Rows) ColumnTypePrecisionScale added in v3.7.0

func (rs *Rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool)

func (*Rows) ColumnTypeScanType added in v3.5.6

func (rs *Rows) ColumnTypeScanType(i int) reflect.Type

func (*Rows) Columns added in v3.5.6

func (rs *Rows) Columns() []string

func (*Rows) Next added in v3.5.6

func (rs *Rows) Next(dest []driver.Value) error

type SetTableNameReq

type SetTableNameReq struct {
	ReqID  uint64 `json:"req_id"`
	StmtID uint64 `json:"stmt_id"`
	Name   string `json:"name"`
}

type SetTableNameResp

type SetTableNameResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Action  string `json:"action"`
	ReqID   uint64 `json:"req_id"`
	Timing  int64  `json:"timing"`
	StmtID  uint64 `json:"stmt_id"`
}

type SetTagsReq

type SetTagsReq struct {
	ReqID  uint64          `json:"req_id"`
	StmtID uint64          `json:"stmt_id"`
	Tags   json.RawMessage `json:"tags"`
}

type SetTagsResp

type SetTagsResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Action  string `json:"action"`
	ReqID   uint64 `json:"req_id"`
	Timing  int64  `json:"timing"`
	StmtID  uint64 `json:"stmt_id"`
}

type Stmt

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

func (*Stmt) AddBatch

func (s *Stmt) AddBatch() error

func (*Stmt) BindParam

func (s *Stmt) BindParam(params []*param.Param, bindType *param.ColumnType) error

func (*Stmt) Close

func (s *Stmt) Close() error

func (*Stmt) Exec

func (s *Stmt) Exec() error

func (*Stmt) GetAffectedRows

func (s *Stmt) GetAffectedRows() int

func (*Stmt) Prepare

func (s *Stmt) Prepare(sql string) error

func (*Stmt) SetTableName

func (s *Stmt) SetTableName(name string) error

func (*Stmt) SetTags

func (s *Stmt) SetTags(tags *param.Param, bindType *param.ColumnType) error

func (*Stmt) UseResult added in v3.5.6

func (s *Stmt) UseResult() (*Rows, error)

type UseResultReq added in v3.5.6

type UseResultReq struct {
	ReqID  uint64 `json:"req_id"`
	StmtID uint64 `json:"stmt_id"`
}

type UseResultResp added in v3.5.6

type UseResultResp struct {
	Code             int      `json:"code"`
	Message          string   `json:"message"`
	Action           string   `json:"action"`
	ReqID            uint64   `json:"req_id"`
	Timing           int64    `json:"timing"`
	StmtID           uint64   `json:"stmt_id"`
	ResultID         uint64   `json:"result_id"`
	FieldsCount      int      `json:"fields_count"`
	FieldsNames      []string `json:"fields_names"`
	FieldsTypes      []uint8  `json:"fields_types"`
	FieldsLengths    []int64  `json:"fields_lengths"`
	Precision        int      `json:"precision"`
	FieldsPrecisions []int64  `json:"fields_precisions"`
	FieldsScales     []int64  `json:"fields_scales"`
}

type WSConn added in v3.7.0

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

WSConn is a websocket connection, which is used to communicate with the server.

func NewWSConn added in v3.7.0

func NewWSConn(client *client.Client, writeTimeout time.Duration, readTimeout time.Duration) *WSConn

func (*WSConn) Close added in v3.7.0

func (c *WSConn) Close()

type WSFetchBlockReq added in v3.5.6

type WSFetchBlockReq struct {
	ReqID uint64 `json:"req_id"`
	ID    uint64 `json:"id"`
}

type WSFetchReq added in v3.5.6

type WSFetchReq struct {
	ReqID uint64 `json:"req_id"`
	ID    uint64 `json:"id"`
}

type WSFetchResp added in v3.5.6

type WSFetchResp struct {
	Code      int    `json:"code"`
	Message   string `json:"message"`
	Action    string `json:"action"`
	ReqID     uint64 `json:"req_id"`
	Timing    int64  `json:"timing"`
	ID        uint64 `json:"id"`
	Completed bool   `json:"completed"`
	Lengths   []int  `json:"lengths"`
	Rows      int    `json:"rows"`
}

type WSFreeResultRequest added in v3.5.6

type WSFreeResultRequest struct {
	ReqID uint64 `json:"req_id"`
	ID    uint64 `json:"id"`
}

Jump to

Keyboard shortcuts

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