stmt

package
v3.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 16 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"
)

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
}

func NewConfig

func NewConfig(url string, chanLength uint) *Config

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) SetErrorHandler

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

func (*Config) SetMessageTimeout

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

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

Jump to

Keyboard shortcuts

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