server

package
v0.0.0-...-40faf7d Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2016 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnInfo

type ColumnInfo struct {
	Schema             string
	Table              string
	OrgTable           string
	Name               string
	OrgName            string
	ColumnLength       uint32
	Charset            uint16
	Flag               uint16
	Decimal            uint8
	Type               uint8
	DefaultValueLength uint64
	DefaultValue       []byte
}

ColumnInfo contains information of a column

func (*ColumnInfo) Dump

func (column *ColumnInfo) Dump(alloc arena.Allocator) []byte

Dump dumps ColumnInfo to bytes.

type Config

type Config struct {
	Addr         string `json:"addr" toml:"addr"`
	LogLevel     string `json:"log_level" toml:"log_level"`
	SkipAuth     bool   `json:"skip_auth" toml:"skip_auth"`
	StatusAddr   string `json:"status_addr" toml:"status_addr"`
	Socket       string `json:"socket" toml:"socket"`
	ReportStatus bool   `json:"report_status" toml:"report_status"`
}

Config contains configuration options.

type IContext

type IContext interface {
	// Status returns server status code.
	Status() uint16

	// LastInsertID returns last inserted ID.
	LastInsertID() uint64

	// AffectedRows returns affected rows of last executed command.
	AffectedRows() uint64

	// Value returns the value associated with this context for key.
	Value(key fmt.Stringer) interface{}

	// SetValue saves a value associated with this context for key.
	SetValue(key fmt.Stringer, value interface{})

	// CommitTxn commits the transaction operations.
	CommitTxn() error

	// RollbackTxn undoes the transaction operations.
	RollbackTxn() error

	// WarningCount returns warning count of last executed command.
	WarningCount() uint16

	// CurrentDB returns current DB.
	CurrentDB() string

	// Execute executes a SQL statement.
	Execute(sql string) ([]ResultSet, error)

	// SetClientCapability sets client capability flags
	SetClientCapability(uint32)

	// Prepare prepares a statement.
	Prepare(sql string) (statement IStatement, columns, params []*ColumnInfo, err error)

	// GetStatement gets IStatement by statement ID.
	GetStatement(stmtID int) IStatement

	// FieldList returns columns of a table.
	FieldList(tableName string) (columns []*ColumnInfo, err error)

	// Close closes the IContext.
	Close() error

	// Auth verifies user's authentication.
	Auth(user string, auth []byte, salt []byte) bool
}

IContext is the interface to execute command.

type IDriver

type IDriver interface {
	// OpenCtx opens an IContext with connection id, client capability, collation and dbname.
	OpenCtx(connID uint64, capability uint32, collation uint8, dbname string) (IContext, error)
}

IDriver opens IContext.

type IStatement

type IStatement interface {
	// ID returns statement ID
	ID() int

	// Execute executes the statement.
	Execute(args ...interface{}) (ResultSet, error)

	// AppendParam appends parameter to the statement.
	AppendParam(paramID int, data []byte) error

	// NumParams returns number of parameters.
	NumParams() int

	// BoundParams returns bound parameters.
	BoundParams() [][]byte

	// Reset removes all bound parameters.
	Reset()

	// Close closes the statement.
	Close() error
}

IStatement is the interface to use a prepared statement.

type ResultSet

type ResultSet interface {
	Columns() ([]*ColumnInfo, error)
	Next() ([]types.Datum, error)
	Close() error
}

ResultSet is the result set of an query.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the MySQL protocol server

func NewServer

func NewServer(cfg *Config, driver IDriver) (*Server, error)

NewServer creates a new Server.

func (*Server) Close

func (s *Server) Close()

Close closes the server.

func (*Server) ConnectionCount

func (s *Server) ConnectionCount() int

ConnectionCount gets current connection count.

func (*Server) Run

func (s *Server) Run() error

Run runs the server.

type TiDBContext

type TiDBContext struct {
	// contains filtered or unexported fields
}

TiDBContext implements IContext.

func (*TiDBContext) AffectedRows

func (tc *TiDBContext) AffectedRows() uint64

AffectedRows implements IContext AffectedRows method.

func (*TiDBContext) Auth

func (tc *TiDBContext) Auth(user string, auth []byte, salt []byte) bool

Auth implements IContext Auth method.

func (*TiDBContext) Close

func (tc *TiDBContext) Close() (err error)

Close implements IContext Close method.

func (*TiDBContext) CommitTxn

func (tc *TiDBContext) CommitTxn() error

CommitTxn implements IContext CommitTxn method.

func (*TiDBContext) CurrentDB

func (tc *TiDBContext) CurrentDB() string

CurrentDB implements IContext CurrentDB method.

func (*TiDBContext) Execute

func (tc *TiDBContext) Execute(sql string) (rs []ResultSet, err error)

Execute implements IContext Execute method.

func (*TiDBContext) FieldList

func (tc *TiDBContext) FieldList(table string) (colums []*ColumnInfo, err error)

FieldList implements IContext FieldList method.

func (*TiDBContext) GetStatement

func (tc *TiDBContext) GetStatement(stmtID int) IStatement

GetStatement implements IContext GetStatement method.

func (*TiDBContext) LastInsertID

func (tc *TiDBContext) LastInsertID() uint64

LastInsertID implements IContext LastInsertID method.

func (*TiDBContext) Prepare

func (tc *TiDBContext) Prepare(sql string) (statement IStatement, columns, params []*ColumnInfo, err error)

Prepare implements IContext Prepare method.

func (*TiDBContext) RollbackTxn

func (tc *TiDBContext) RollbackTxn() error

RollbackTxn implements IContext RollbackTxn method.

func (*TiDBContext) SetClientCapability

func (tc *TiDBContext) SetClientCapability(flags uint32)

SetClientCapability implements IContext SetClientCapability method.

func (*TiDBContext) SetValue

func (tc *TiDBContext) SetValue(key fmt.Stringer, value interface{})

SetValue implements IContext SetValue method.

func (*TiDBContext) Status

func (tc *TiDBContext) Status() uint16

Status implements IContext Status method.

func (*TiDBContext) Value

func (tc *TiDBContext) Value(key fmt.Stringer) interface{}

Value implements IContext Value method.

func (*TiDBContext) WarningCount

func (tc *TiDBContext) WarningCount() uint16

WarningCount implements IContext WarningCount method.

type TiDBDriver

type TiDBDriver struct {
	// contains filtered or unexported fields
}

TiDBDriver implements IDriver.

func NewTiDBDriver

func NewTiDBDriver(store kv.Storage) *TiDBDriver

NewTiDBDriver creates a new TiDBDriver.

func (*TiDBDriver) OpenCtx

func (qd *TiDBDriver) OpenCtx(connID uint64, capability uint32, collation uint8, dbname string) (IContext, error)

OpenCtx implements IDriver.

type TiDBStatement

type TiDBStatement struct {
	// contains filtered or unexported fields
}

TiDBStatement implements IStatement.

func (*TiDBStatement) AppendParam

func (ts *TiDBStatement) AppendParam(paramID int, data []byte) error

AppendParam implements IStatement AppendParam method.

func (*TiDBStatement) BoundParams

func (ts *TiDBStatement) BoundParams() [][]byte

BoundParams implements IStatement BoundParams method.

func (*TiDBStatement) Close

func (ts *TiDBStatement) Close() error

Close implements IStatement Close method.

func (*TiDBStatement) Execute

func (ts *TiDBStatement) Execute(args ...interface{}) (rs ResultSet, err error)

Execute implements IStatement Execute method.

func (*TiDBStatement) ID

func (ts *TiDBStatement) ID() int

ID implements IStatement ID method.

func (*TiDBStatement) NumParams

func (ts *TiDBStatement) NumParams() int

NumParams implements IStatement NumParams method.

func (*TiDBStatement) Reset

func (ts *TiDBStatement) Reset()

Reset implements IStatement Reset method.

type Token

type Token struct {
}

Token is used as a permission to keep on running.

type TokenLimiter

type TokenLimiter struct {
	// contains filtered or unexported fields
}

TokenLimiter is used to limit the number of concurrent tasks.

func NewTokenLimiter

func NewTokenLimiter(count int) *TokenLimiter

NewTokenLimiter creates a TokenLimiter with count tokens.

func (*TokenLimiter) Get

func (tl *TokenLimiter) Get() *Token

Get obtains a token.

func (*TokenLimiter) Put

func (tl *TokenLimiter) Put(tk *Token)

Put releases the token.

Jump to

Keyboard shortcuts

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