Documentation ¶
Index ¶
- Constants
- type AuthHandler
- type BaseExecutor
- func (executor *BaseExecutor) AlterDatabase(conn *Conn, stmt *query.Database) (*Result, error)
- func (executor *BaseExecutor) AlterTable(conn *Conn, stmt *query.Schema) (*Result, error)
- func (executor *BaseExecutor) Begin(conn *Conn, stmt *query.Begin) (*Result, error)
- func (executor *BaseExecutor) Commit(conn *Conn, stmt *query.Commit) (*Result, error)
- func (executor *BaseExecutor) CreateDatabase(conn *Conn, stmt *query.Database) (*Result, error)
- func (executor *BaseExecutor) CreateTable(conn *Conn, stmt *query.Schema) (*Result, error)
- func (executor *BaseExecutor) Delete(conn *Conn, stmt *query.Delete) (*Result, error)
- func (executor *BaseExecutor) DropDatabase(conn *Conn, stmt *query.Database) (*Result, error)
- func (executor *BaseExecutor) DropTable(conn *Conn, stmt *query.Schema) (*Result, error)
- func (executor *BaseExecutor) Insert(conn *Conn, stmt *query.Insert) (*Result, error)
- func (executor *BaseExecutor) RenameTable(conn *Conn, stmt *query.Schema) (*Result, error)
- func (executor *BaseExecutor) Rollback(conn *Conn, stmt *query.Rollback) (*Result, error)
- func (executor *BaseExecutor) Select(conn *Conn, stmt *query.Select) (*Result, error)
- func (executor *BaseExecutor) ShowDatabases(conn *Conn) (*Result, error)
- func (executor *BaseExecutor) ShowTables(conn *Conn, database string) (*Result, error)
- func (executor *BaseExecutor) TruncateTable(conn *Conn, stmt *query.Schema) (*Result, error)
- func (executor *BaseExecutor) Update(conn *Conn, stmt *query.Update) (*Result, error)
- type BindVariable
- type Client
- type Config
- type Conn
- func (conn *Conn) Database() string
- func (conn *Conn) ID() uint32
- func (conn *Conn) SetDatabase(name string)
- func (conn *Conn) SetDeadline(t time.Time) error
- func (conn *Conn) SetReadDeadline(t time.Time) error
- func (conn *Conn) SetSpanContext(span tracer.Context)
- func (conn *Conn) SetWriteDeadline(t time.Time) error
- func (conn *Conn) SpanContext() tracer.Context
- func (conn *Conn) Timestamp() time.Time
- func (conn *Conn) UUID() uuid.UUID
- type ConnMap
- type DAOExecutor
- type DCOExecutor
- type DDOExecutor
- type DMOExecutor
- type Field
- type Listener
- type MySQLClient
- type PrepareData
- type QueryExecutor
- type QueryHandler
- type Result
- type Server
- func (server *Server) ComInitDB(c *vitessmy.Conn, dbName string)
- func (server *Server) ComPrepare(c *vitessmy.Conn, query string, bindVars map[string]*BindVariable) ([]*Field, error)
- func (server *Server) ComQuery(c *vitessmy.Conn, q string, callback func(*Result) error) error
- func (server *Server) ComResetConnection(c *vitessmy.Conn)
- func (server *Server) ComStmtExecute(c *vitessmy.Conn, prepare *PrepareData, callback func(*Result) error) error
- func (server *Server) ConnectionClosed(c *vitessmy.Conn)
- func (server *Server) NewConnection(c *vitessmy.Conn)
- func (server *Server) Restart() error
- func (server *Server) SetAuthHandler(h AuthHandler)
- func (server *Server) SetQueryExecutor(e QueryExecutor)
- func (server *Server) SetTracer(t tracer.Tracer)
- func (server *Server) Start() error
- func (server *Server) Stop() error
- func (server *Server) WarningCount(c *vitessmy.Conn) uint16
- type TCLExecutor
- type Value
Constants ¶
const (
// PackageName is the package name.
PackageName = "go-mysql"
)
const (
Version = "v1.0.4"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthHandler ¶
type AuthHandler interface { vitessmy.AuthServer }
A AuthHandler is an interface used for the user authentication.
func NewDefaultAuthHandler ¶
func NewDefaultAuthHandler() AuthHandler
NewDefaultAuthHandler returns a non authentication handler.
type BaseExecutor ¶
type BaseExecutor struct { }
BaseExecutor is a stub listener to implement only target executor functions.
func NewBaseExecutor ¶
func NewBaseExecutor() *BaseExecutor
NewBaseExecutor returns an in-memory executorinstance.
func (*BaseExecutor) AlterDatabase ¶
AlterDatabase should handle a ALTER database statement.
func (*BaseExecutor) AlterTable ¶
AlterTable should handle a ALTER table statement.
func (*BaseExecutor) CreateDatabase ¶
CreateDatabase should handle a CREATE database statement.
func (*BaseExecutor) CreateTable ¶
CreateTable should handle a CREATE table statement.
func (*BaseExecutor) DropDatabase ¶
DropDatabase should handle a DROP database statement.
func (*BaseExecutor) RenameTable ¶
RenameTable should handle a RENAME table statement.
func (*BaseExecutor) ShowDatabases ¶
func (executor *BaseExecutor) ShowDatabases(conn *Conn) (*Result, error)
ShowDatabases should handle a SHOW DATABASES statement.
func (*BaseExecutor) ShowTables ¶
func (executor *BaseExecutor) ShowTables(conn *Conn, database string) (*Result, error)
ShowTables should handle a SHOW TABLES statement.
func (*BaseExecutor) TruncateTable ¶
TruncateTable should handle a TRUNCATE table statement.
type BindVariable ¶
type BindVariable = vitesspq.BindVariable
BindVariable represents a single bind variable.
type Client ¶
type Client struct { *Config // contains filtered or unexported fields }
Client represents a client for MySQL server.
type Config ¶
Config stores server configuration parammeters.
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig returns a default configuration instance.
func (*Config) SetAddress ¶ added in v1.0.0
SetAddress sets a listen address.
func (*Config) SetDatabase ¶
SetDatabase sets a host database.
type Conn ¶
type Conn struct { *vitessmy.Conn sync.Map tracer.Context // contains filtered or unexported fields }
Conn represents a connection of MySQL binary protocol.
func NewConnWith ¶ added in v1.0.2
NewConnWith returns a connection with a raw connection.
func (*Conn) SetDatabase ¶ added in v0.9.2
SetDatabase sets th selected database to the connection.
func (*Conn) SetDeadline ¶ added in v1.0.5
SetDeadline sets the read and write deadlines associated with the connection.
func (*Conn) SetReadDeadline ¶ added in v1.0.5
SetReadDeadline sets the deadline for future Read calls.
func (*Conn) SetSpanContext ¶ added in v1.0.1
SetSpanContext sets the tracer span context to the connection.
func (*Conn) SetWriteDeadline ¶ added in v1.0.5
SetWriteDeadline sets the deadline for future Write calls.
func (*Conn) SpanContext ¶ added in v1.0.1
SpanContext returns the tracer span context of the connection.
type ConnMap ¶
type ConnMap struct {
// contains filtered or unexported fields
}
ConnMap represents a connection map.
func (ConnMap) DeleteConnByUID ¶
DeleteConnByUID deletes the specified connection by the connection ID.
func (ConnMap) GetConnByUID ¶
GetConnByUID returns a connection and true when the specified connection exists by the connection ID, otherwise nil and false.
type DAOExecutor ¶
type DAOExecutor interface { // ShowDatabases should handle a SHOW DATABASES statement. ShowDatabases(*Conn) (*Result, error) // ShowTables should handle a SHOW TABLES statement. ShowTables(*Conn, string) (*Result, error) }
DAOExecutor defines a executor interface for DAO (Database Administration Operations).
type DCOExecutor ¶
type DCOExecutor interface { }
DCOExecutor defines a executor interface for DCO (Data Control Operations).
type DDOExecutor ¶
type DDOExecutor interface { // CreateDatabase should handle a CREATE database statement. CreateDatabase(*Conn, *query.Database) (*Result, error) // AlterDatabase should handle a ALTER database statement. AlterDatabase(*Conn, *query.Database) (*Result, error) // DropDatabase should handle a DROP database statement. DropDatabase(*Conn, *query.Database) (*Result, error) // CreateTable should handle a CREATE table statement. CreateTable(*Conn, *query.Schema) (*Result, error) // AlterTable should handle a ALTER table statement. AlterTable(*Conn, *query.Schema) (*Result, error) // DropTable should handle a DROP table statement. DropTable(*Conn, *query.Schema) (*Result, error) // RenameTable should handle a RENAME table statement. RenameTable(*Conn, *query.Schema) (*Result, error) // TruncateTable should handle a TRUNCATE table statement. TruncateTable(*Conn, *query.Schema) (*Result, error) }
DDOExecutor defines a executor interface for DDO (Data Definition Operations).
type DMOExecutor ¶
type DMOExecutor interface { // Insert should handle a INSERT statement. Insert(*Conn, *query.Insert) (*Result, error) // Update should handle a UPDATE statement. Update(*Conn, *query.Update) (*Result, error) // Delete should handle a DELETE statement. Delete(*Conn, *query.Delete) (*Result, error) // Select should handle a SELECT statement. Select(*Conn, *query.Select) (*Result, error) }
DMOExecutor defines a executor interface for DMO (Data Manipulation Operations).
type Listener ¶
Listener is the MySQL server protocol listener.
func NewListener ¶
func NewListener(protocol, address string, authServer AuthHandler, handler QueryHandler, connReadTimeout time.Duration, connWriteTimeout time.Duration, proxyProtocol bool) (*Listener, error)
NewListener creates a new listener.
type MySQLClient ¶
type MySQLClient struct { *Config // contains filtered or unexported fields }
Client represents a client for MySQL server.
func (*MySQLClient) Close ¶
func (client *MySQLClient) Close() error
Close closes opens a database specified by the internal configuration.
func (*MySQLClient) Open ¶
func (client *MySQLClient) Open(dbName string) error
Open opens a database specified by the internal configuration.
type PrepareData ¶
type PrepareData = vitessmy.PrepareData
PrepareData is a buffer used for store prepare statement meta data.
type QueryExecutor ¶
type QueryExecutor interface { DDOExecutor DMOExecutor DCOExecutor DAOExecutor TCLExecutor }
QueryExecutor represents an interface to execute all SQL queries.
type QueryHandler ¶
A QueryHandler is an interface used for the request queries.
type Result ¶
Result represents a query result.
func NewResultWithRows ¶
NewResultWithRows returns a successful result with the specified rows.
func NewResultWithRowsAffected ¶
NewResultWithRowsAffected returns a successful result with the specified rows affected count.
type Server ¶
type Server struct { tracer.Tracer AuthHandler QueryHandler *Config ConnMap // contains filtered or unexported fields }
Server represents a MySQL-compatible server.
func (*Server) ComInitDB ¶
ComInitDB is called once at the beginning to set db name, and subsequently for every ComInitDB event.
func (*Server) ComPrepare ¶
func (server *Server) ComPrepare(c *vitessmy.Conn, query string, bindVars map[string]*BindVariable) ([]*Field, error)
ComPrepare is called when a connection receives a prepared statement query.
func (*Server) ComResetConnection ¶
ComResetConnection is called when the connection is reseted.
func (*Server) ComStmtExecute ¶
func (server *Server) ComStmtExecute(c *vitessmy.Conn, prepare *PrepareData, callback func(*Result) error) error
ComStmtExecute is called when a connection receives a statement execute query.
func (*Server) ConnectionClosed ¶
ConnectionClosed is called when a connection is closed.
func (*Server) NewConnection ¶
NewConnection is called when a connection is created.
func (*Server) SetAuthHandler ¶
func (server *Server) SetAuthHandler(h AuthHandler)
SetAuthHandler sets a user authentication handler.
func (*Server) SetQueryExecutor ¶
func (server *Server) SetQueryExecutor(e QueryExecutor)
SetQueryExecutor sets a query executor.
type TCLExecutor ¶ added in v1.0.5
type TCLExecutor interface { // Begin should handle a BEGIN statement. Begin(*Conn, *query.Begin) (*Result, error) // Commit should handle a COMMIT statement. Commit(*Conn, *query.Commit) (*Result, error) // Rollback should handle a ROLLBACK statement. Rollback(*Conn, *query.Rollback) (*Result, error) }
TCLExecutor defines a executor interface for TXN (Transaction Operations).