server

package
v0.10.1-0...-0d403c5 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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()
)
View Source
var ErrConnectionWasClosed = errors.NewKind("connection was closed")

ErrConnectionWasClosed will be returned if we try to use a previously closed connection

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

View Source
var ErrUnsupportedOperation = errors.NewKind("unsupported operation")

Functions

func DefaultSessionBuilder

func DefaultSessionBuilder(ctx context.Context, c *mysql.Conn, addr string) (sql.Session, *sql.IndexRegistry, *sql.ViewRegistry, error)

DefaultSessionBuilder is a SessionBuilder that returns a base session.

Types

type Config

type Config struct {
	// Protocol for the connection.
	Protocol string
	// Address of the server.
	Address string
	// Auth of the server.
	Auth auth.Auth
	// Tracer to use in the server. By default, a noop tracer will be used if
	// no tracer is provided.
	Tracer opentracing.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
}

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.

func NewHandler

func NewHandler(e *sqle.Engine, sm *SessionManager, rt time.Duration) *Handler

NewHandler creates a new Handler given a SQLe engine.

func (*Handler) ComInitDB

func (h *Handler) ComInitDB(c *mysql.Conn, schemaName string) error

func (*Handler) ComPrepare

func (h *Handler) ComPrepare(c *mysql.Conn, query string) ([]*query.Field, error)

func (*Handler) ComQuery

func (h *Handler) ComQuery(
	c *mysql.Conn,
	query string,
	callback func(*sqltypes.Result) error,
) error

ComQuery executes a SQL query on the SQLe engine.

func (*Handler) ComResetConnection

func (h *Handler) ComResetConnection(c *mysql.Conn)

func (*Handler) ComStmtExecute

func (h *Handler) ComStmtExecute(c *mysql.Conn, prepare *mysql.PrepareData, callback func(*sqltypes.Result) error) error

func (*Handler) ConnectionClosed

func (h *Handler) ConnectionClosed(c *mysql.Conn)

ConnectionClosed reports that a connection has been closed.

func (*Handler) NewConnection

func (h *Handler) NewConnection(c *mysql.Conn)

NewConnection reports that a new connection has been established.

func (*Handler) WarningCount

func (h *Handler) WarningCount(c *mysql.Conn) uint16

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 {
	net.Listener
	// contains filtered or unexported fields
}

func NewListener

func NewListener(protocol, address string, handler *Handler) (*Listener, error)

NewListener creates a new Listener.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

type Server

type Server struct {
	Listener *mysql.Listener
	// contains filtered or unexported fields
}

Server is a MySQL server for SQLe engines.

func NewDefaultServer

func NewDefaultServer(cfg Config, e *sqle.Engine) (*Server, error)

NewDefaultServer creates a Server with the default session builder.

func NewServer

func NewServer(cfg Config, e *sqle.Engine, sb SessionBuilder) (*Server, error)

NewServer creates a server with the given protocol, address, authentication details given a SQLe engine and a session builder.

func (*Server) Close

func (s *Server) Close() error

Close closes the server connection.

func (*Server) Start

func (s *Server) Start() error

Start starts accepting connections on the server.

type SessionBuilder

type SessionBuilder func(ctx context.Context, conn *mysql.Conn, addr string) (sql.Session, *sql.IndexRegistry, *sql.ViewRegistry, error)

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 opentracing.Tracer,
	hasDBFunc func(name string) bool,
	memory *sql.MemoryManager,
	addr string,
) *SessionManager

NewSessionManager creates a SessionManager with the given SessionBuilder.

func (*SessionManager) CloseConn

func (s *SessionManager) CloseConn(conn *mysql.Conn)

CloseConn closes the connection in the session manager and all its associated contexts, which are cancelled.

func (*SessionManager) NewContext

func (s *SessionManager) NewContext(conn *mysql.Conn) (*sql.Context, error)

NewContext creates a new context for the session at the given conn.

func (*SessionManager) NewContextWithQuery

func (s *SessionManager) NewContextWithQuery(conn *mysql.Conn, query string) (*sql.Context, error)

NewContextWithQuery creates a new context for the session at the given conn.

func (*SessionManager) NewSession

func (s *SessionManager) NewSession(ctx context.Context, conn *mysql.Conn) error

NewSession creates a Session for the given connection and saves it to session pool.

func (*SessionManager) SetDB

func (s *SessionManager) SetDB(conn *mysql.Conn, db string) error

Jump to

Keyboard shortcuts

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