Documentation ¶
Index ¶
- Variables
- func DefaultSessionBuilder(ctx context.Context, c *mysql.Conn, addr string) (sql.Session, error)
- type Config
- type DoneFunc
- type Handler
- func (h *Handler) ComInitDB(c *mysql.Conn, schemaName string) error
- func (h *Handler) ComMultiQuery(c *mysql.Conn, query string, callback func(*sqltypes.Result, bool) error) (string, error)
- func (h *Handler) ComPrepare(c *mysql.Conn, query string) ([]*query.Field, error)
- func (h *Handler) ComQuery(c *mysql.Conn, query string, callback func(*sqltypes.Result, bool) error) error
- func (h *Handler) ComResetConnection(c *mysql.Conn)
- func (h *Handler) ComStmtExecute(c *mysql.Conn, prepare *mysql.PrepareData, ...) error
- func (h *Handler) ConnectionClosed(c *mysql.Conn)
- func (h *Handler) NewConnection(c *mysql.Conn)
- func (h *Handler) WarningCount(c *mysql.Conn) uint16
- type Listener
- type MultiStmtMode
- type Server
- type ServerEventListener
- type SessionBuilder
- type SessionManager
- func (s *SessionManager) CloseConn(conn *mysql.Conn)
- func (s *SessionManager) Iter(f func(session sql.Session) (stop bool, err error)) error
- func (s *SessionManager) KillConnection(connID uint32) error
- func (s *SessionManager) NewContext(conn *mysql.Conn) (*sql.Context, error)
- func (s *SessionManager) NewContextWithQuery(conn *mysql.Conn, query string) (*sql.Context, error)
- func (s *SessionManager) NewSession(ctx context.Context, conn *mysql.Conn) error
- func (s *SessionManager) SetDB(conn *mysql.Conn, db string) error
Constants ¶
This section is empty.
Variables ¶
var ( // QueryCounter describes a metric that accumulates number of queries monotonically. QueryCounter = discard.NewCounter() // QueryErrorCounter describes a metric that accumulates number of failed queries monotonically. QueryErrorCounter = discard.NewCounter() // QueryHistogram describes a queries latency. QueryHistogram = discard.NewHistogram() )
var ErrConnectionWasClosed = errors.NewKind("connection was closed")
ErrConnectionWasClosed will be returned if we try to use a previously closed connection
var ErrRowTimeout = errors.NewKind("row read wait bigger than connection timeout")
ErrRowTimeout will be returned if the wait for the row is longer than the connection timeout
var ErrUnsupportedOperation = errors.NewKind("unsupported operation")
var UnixSocketInUseError = errors.New("bind address at given unix socket path is already in use")
Functions ¶
Types ¶
type Config ¶
type Config struct { // Protocol for the connection. Protocol string // Address of the server. Address string // Tracer to use in the server. By default, a noop tracer will be used if // no tracer is provided. Tracer trace.Tracer // Version string to advertise in running server Version string // ConnReadTimeout is the server's read timeout ConnReadTimeout time.Duration // ConnWriteTimeout is the server's write timeout ConnWriteTimeout time.Duration // MaxConnections is the maximum number of simultaneous connections that the server will allow. MaxConnections uint64 // TLSConfig is the configuration for TLS on this server. If |nil|, TLS is not supported. TLSConfig *tls.Config // RequestSecureTransport will require incoming connections to be TLS. Requires non-|nil| TLSConfig. RequireSecureTransport bool // DisableClientMultiStatements will prevent processing of incoming // queries as if they contain more than one query. This processing // currently works in some simple cases, but breaks in the presence of // statements (such as in CREATE TRIGGER queries). Configuring the // server to disable processing these is one option for users to get // support back for single queries that contain statements, at the cost // of not supporting the CLIENT_MULTI_STATEMENTS option on the server. DisableClientMultiStatements bool // NoDefaults prevents using persisted configuration for new server sessions NoDefaults bool // Socket is a path to unix socket file Socket string AllowClearTextWithoutTLS bool }
Config for the mysql server.
type DoneFunc ¶
type DoneFunc func()
DoneFunc is a function that must be executed when the session is used and it can be disposed.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a connection handler for a SQLe engine, implementing the Vitess mysql.Handler interface.
func NewHandler ¶
func NewHandler(e *sqle.Engine, sm *SessionManager, rt time.Duration, disableMultiStmts bool, listener ServerEventListener) *Handler
NewHandler creates a new Handler given a SQLe engine.
func (*Handler) ComMultiQuery ¶
func (*Handler) ComPrepare ¶
ComPrepare parses, partially analyzes, and caches a prepared statement's plan with the given [c.ConnectionID].
func (*Handler) ComQuery ¶
func (h *Handler) ComQuery( c *mysql.Conn, query string, callback func(*sqltypes.Result, bool) error, ) error
ComQuery executes a SQL query on the SQLe engine.
func (*Handler) ComResetConnection ¶
func (*Handler) ComStmtExecute ¶
func (*Handler) ConnectionClosed ¶
ConnectionClosed reports that a connection has been closed.
func (*Handler) NewConnection ¶
NewConnection reports that a new connection has been established.
func (*Handler) WarningCount ¶
WarningCount is called at the end of each query to obtain the value to be returned to the client in the EOF packet. Note that this will be called either in the context of the ComQuery callback if the result does not contain any fields, or after the last ComQuery call completes.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener implements a single listener with two net.Listener, one for TCP socket and another for unix socket connections.
func NewListener ¶
NewListener creates a new Listener. 'protocol' takes "tcp" and 'address' takes "host:port" information for TCP socket connection. For unix socket connection, 'unixSocketPath' takes a path for the unix socket file. If 'unixSocketPath' is empty, no need to create the second listener.
type MultiStmtMode ¶
type MultiStmtMode int
const ( MultiStmtModeOff MultiStmtMode = 0 MultiStmtModeOn MultiStmtMode = 1 )
type Server ¶
Server is a MySQL server for SQLe engines.
func NewDefaultServer ¶
NewDefaultServer creates a Server with the default session builder.
func NewServer ¶
func NewServer(cfg Config, e *sqle.Engine, sb SessionBuilder, listener ServerEventListener) (*Server, error)
NewServer creates a server with the given protocol, address, authentication details given a SQLe engine and a session builder.
func NewValidatingServer ¶
func NewValidatingServer( cfg Config, e *sqle.Engine, sb SessionBuilder, listener ServerEventListener, mySqlConn string, ) (*Server, error)
NewValidatingServer creates a Server that validates its query results using a MySQL connection as a source of golden-value query result sets.
func (*Server) SessionManager ¶
func (s *Server) SessionManager() *SessionManager
SessionManager returns the session manager for this server.
type ServerEventListener ¶
type SessionBuilder ¶
SessionBuilder creates sessions given a MySQL connection and a server address.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager is in charge of creating new sessions for the given connections and keep track of which sessions are in each connection, so they can be cancelled if the connection is closed.
func NewSessionManager ¶
func NewSessionManager( builder SessionBuilder, tracer trace.Tracer, hasDBFunc func(ctx *sql.Context, name string) bool, memory *sql.MemoryManager, processlist sql.ProcessList, addr string, ) *SessionManager
NewSessionManager creates a SessionManager with the given SessionBuilder.
func (*SessionManager) CloseConn ¶
func (s *SessionManager) CloseConn(conn *mysql.Conn)
Remove the session assosiated with |conn| from the session manager.
func (*SessionManager) Iter ¶
Iter iterates over the active sessions and executes the specified callback function on each one.
func (*SessionManager) KillConnection ¶
func (s *SessionManager) KillConnection(connID uint32) error
Exposed through sql.Services.KillConnection. At the time that this is called, any outstanding process has been killed through ProcessList.Kill() as well.
func (*SessionManager) NewContext ¶
NewContext creates a new context for the session at the given conn.
func (*SessionManager) NewContextWithQuery ¶
NewContextWithQuery creates a new context for the session at the given conn.
func (*SessionManager) NewSession ¶
NewSession creates a Session for the given connection and saves it to the session pool.