stmt

package
v3.30.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 25 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 (
	ConnectTimeoutErr = errors.New("stmt connect timeout")
)

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

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

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

func (c *Config) SetReconnectIntervalMs(reconnectIntervalMs int)

func (*Config) SetReconnectRetryCount

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 {
	// 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

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

func (*Rows) Close

func (rs *Rows) Close() error

func (*Rows) ColumnTypeDatabaseTypeName

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

func (*Rows) ColumnTypeLength

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

func (*Rows) ColumnTypeScanType

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

func (*Rows) Columns

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

func (*Rows) Next

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

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

type UseResultReq

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

type UseResultResp

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"`
}

type WSFetchBlockReq

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

type WSFetchReq

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

type WSFetchResp

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

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