Documentation ¶
Index ¶
- func CommandType(ctx context.Context) byte
- func ConnectionID(ctx context.Context) uint32
- func IsMaster(ctx context.Context) bool
- func IsSlave(ctx context.Context) bool
- func QueryStmt(ctx context.Context) ast.StmtNode
- func RemoteAddr(ctx context.Context) string
- func Schema(ctx context.Context) string
- func SqlText(ctx context.Context) string
- func UserName(ctx context.Context) string
- func Variable(ctx context.Context, key string) interface{}
- func WithCommandType(ctx context.Context, commandType byte) context.Context
- func WithConnectionID(ctx context.Context, connectionID uint32) context.Context
- func WithMaster(ctx context.Context) context.Context
- func WithPrepareStmt(ctx context.Context, stmt *Stmt) context.Context
- func WithQueryStmt(ctx context.Context, stmt ast.StmtNode) context.Context
- func WithRemoteAddr(ctx context.Context, remoteAddr string) context.Context
- func WithSchema(ctx context.Context, schema string) context.Context
- func WithSlave(ctx context.Context) context.Context
- func WithSqlText(ctx context.Context, sqlText string) context.Context
- func WithUserName(ctx context.Context, userName string) context.Context
- func WithVariable(ctx context.Context, key string, value interface{}) bool
- func WithVariableMap(ctx context.Context) context.Context
- type Connection
- type DB
- type DBConnectionPostFilter
- type DBConnectionPreFilter
- type DBGroupExecutor
- type DBListener
- type DBManager
- type DBPostFilter
- type DBPreFilter
- type DBStatus
- type Executor
- type Field
- type Filter
- type FilterFactory
- type HttpPostFilter
- type HttpPreFilter
- type Listener
- type Optimizer
- type Plan
- type Result
- type Row
- type Stmt
- type Tx
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectionID ¶
ConnectionID extracts connection id
func RemoteAddr ¶ added in v0.2.0
RemoteAddr extracts remote addr
func WithCommandType ¶
WithCommandType binds command type
func WithConnectionID ¶
WithConnectionID binds connection id
func WithMaster ¶
WithMaster uses master datasource.
func WithPrepareStmt ¶
WithPrepareStmt binds prepare stmt
func WithQueryStmt ¶
WithQueryStmt binds query stmt
func WithRemoteAddr ¶ added in v0.2.0
WithRemoteAddr binds remote address
func WithSchema ¶
WithSchema binds schema
func WithSqlText ¶ added in v0.2.0
WithSqlText binds sql text
func WithUserName ¶ added in v0.2.0
WithUserName binds user name
func WithVariable ¶
WithVariable binds a key value pair
Types ¶
type Connection ¶
type DB ¶
type DB interface { UseDB(ctx context.Context, schema string) error ExecuteFieldList(ctx context.Context, table, wildcard string) ([]Field, error) Query(ctx context.Context, query string) (Result, uint16, error) ExecuteStmt(ctx context.Context, stmt *Stmt) (Result, uint16, error) ExecuteSql(ctx context.Context, sql string, args ...interface{}) (Result, uint16, error) Begin(ctx context.Context) (Tx, Result, error) SetConnectionPreFilters(filters []DBConnectionPreFilter) SetConnectionPostFilters(filters []DBConnectionPostFilter) Name() string Status() DBStatus SetCapacity(capacity int) error SetIdleTimeout(idleTimeout time.Duration) Capacity() int64 Available() int64 Active() int64 InUse() int64 MaxCap() int64 WaitCount() int64 WaitTime() time.Duration IdleTimeout() time.Duration IdleClosed() int64 Exhausted() int64 StatsJSON() string Ping() Close() IsClosed() (closed bool) }
type DBConnectionPostFilter ¶
type DBConnectionPreFilter ¶
type DBConnectionPreFilter interface { Filter PreHandle(ctx context.Context, conn Connection) error }
type DBGroupExecutor ¶
type DBGroupExecutor interface { Begin(ctx context.Context) (Tx, Result, error) Query(ctx context.Context, query string) (Result, uint16, error) Execute(ctx context.Context, query string) (Result, uint16, error) PrepareQuery(ctx context.Context, query string, args ...interface{}) (Result, uint16, error) PrepareExecute(ctx context.Context, query string, args ...interface{}) (Result, uint16, error) }
DBGroupExecutor prepare a query, execute the statement, and then close the statement.
type DBListener ¶
type DBPostFilter ¶
DBPostFilter ...
type DBPreFilter ¶
DBPreFilter ...
type Executor ¶
type Executor interface { GetPreFilters() []DBPreFilter GetPostFilters() []DBPostFilter ExecuteMode() config.ExecuteMode ProcessDistributedTransaction() bool InLocalTransaction(ctx context.Context) bool InGlobalTransaction(ctx context.Context) bool ExecuteUseDB(ctx context.Context, db string) error ExecuteFieldList(ctx context.Context, table, wildcard string) ([]Field, error) ExecutorComQuery(ctx context.Context, sql string) (Result, uint16, error) ExecutorComStmtExecute(ctx context.Context, stmt *Stmt) (Result, uint16, error) ConnectionClose(ctx context.Context) }
Executor ...
type FilterFactory ¶
type HttpPostFilter ¶
type HttpPostFilter interface { Filter PostHandle(ctx *fasthttp.RequestCtx) error }
type HttpPreFilter ¶
type HttpPreFilter interface { Filter PreHandle(ctx *fasthttp.RequestCtx) error }
type Optimizer ¶
type Optimizer interface { // Optimize optimizes the sql with arguments then returns a Plan. Optimize(ctx context.Context, stmt ast.StmtNode, args ...interface{}) (Plan, error) }
Optimizer represents a sql statement optimizer which can be used to create QueryPlan or ExecPlan.
type Plan ¶
type Plan interface { // Execute executes the current Plan. Execute(ctx context.Context, hints ...*ast.TableOptimizerHint) (Result, uint16, error) }
Plan represents a plan for query/execute command.
type Result ¶
type Result interface { // LastInsertId returns the database's auto-generated ID // after, for example, an INSERT into a table with primary // key. LastInsertId() (uint64, error) // RowsAffected returns the number of rows affected by the // query. RowsAffected() (uint64, error) }
Result is the result of a query execution.
type Row ¶
type Row interface { // Columns returns the names of the columns. The number of // columns of the result is inferred from the length of the // slice. If a particular column name isn't known, an empty // string should be returned for that entry. Columns() []string Fields() []Field // Data Data() []byte Decode() ([]*Value, error) }
Rows is an iterator over an executed query's results.
type Stmt ¶
type Stmt struct { StatementID uint32 HasLongDataParam bool SqlText string ParamsCount uint16 ParamData []byte ParamsType []int32 ColumnNames []string BindVars map[string]interface{} StmtNode ast.StmtNode }
Stmt is a buffer used for store prepare statement meta data
type Tx ¶
type Tx interface { Query(ctx context.Context, query string) (Result, uint16, error) ExecuteStmt(ctx context.Context, stmt *Stmt) (Result, uint16, error) ExecuteSql(ctx context.Context, sql string, args ...interface{}) (Result, uint16, error) Commit(ctx context.Context) (Result, error) Rollback(ctx context.Context) (Result, error) }