proxy

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: GPL-3.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttachDatabaseCheckTable = "attach_database_check_table_valid"

	AttachParamsCount = 3
	DetachParamsCount = 1
)
View Source
const (
	// R enum.
	R mode = iota
	// W enum.
	W
)

Variables

This section is empty.

Functions

func MockConfigIdleTxnTimeout1 added in v1.0.6

func MockConfigIdleTxnTimeout1() *config.Config

MockConfigIdleTxnTimeout1 mocks the config with IdleTxnTimeout=1.

func MockConfigMax16

func MockConfigMax16() *config.Config

MockConfigMax16 mocks the config with MaxConnections=16.

func MockDefaultConfig

func MockDefaultConfig() *config.Config

MockDefaultConfig mocks the default config.

func RebalanceMigrate added in v1.1.2

func RebalanceMigrate(log *xlog.Log, rebalance *Rebalance, max, min *BackendSize, database, table string) error

func ShardBalanceAdvice added in v1.1.2

func ShardBalanceAdvice(log *xlog.Log, spanner *Spanner, scatter *backend.Scatter, route *router.Router,
	max, min *BackendSize, database, table *string, tableSize *float64) error

func SubTableToTable added in v1.1.2

func SubTableToTable(from string) (isSub bool, to string)

SubTableToTable used to determine from is subtable or not; if it is, get the table from the subtable.

Types

type AdminXA added in v1.1.2

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

func NewAdminXA added in v1.1.2

func NewAdminXA(log *xlog.Log, scatter *backend.Scatter, router *router.Router, spanner *Spanner) *AdminXA

func (*AdminXA) Commit added in v1.1.2

func (adminXA *AdminXA) Commit() (*sqltypes.Result, error)

Commit used to handle the 'XA COMMIT' to all XAIDs an hour ago.

func (*AdminXA) Recover added in v1.1.2

func (adminXA *AdminXA) Recover() (*sqltypes.Result, error)

Recover used to handle the 'XA RECOVER' to all backends .

func (*AdminXA) Rollback added in v1.1.2

func (adminXA *AdminXA) Rollback() (*sqltypes.Result, error)

Rollback used to handle the 'XA ROLLBACK' to all XAIDs an hour ago.

type Attach added in v1.0.7

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

func NewAttach added in v1.0.7

func NewAttach(log *xlog.Log, scatter *backend.Scatter, router *router.Router, spanner *Spanner) *Attach

NewAttach -- creates new Attach handler.

func (*Attach) Attach added in v1.0.7

func (attach *Attach) Attach(node *sqlparser.Radon) (*sqltypes.Result, error)

func (*Attach) Detach added in v1.0.7

func (attach *Attach) Detach(attachName string) (*sqltypes.Result, error)

func (*Attach) ListAttach added in v1.0.7

func (attach *Attach) ListAttach() (*sqltypes.Result, error)

type BackendSize added in v1.1.2

type BackendSize struct {
	Name    string
	Address string
	Size    float64
	User    string
	Passwd  string
}

type Cleanup added in v1.0.9

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

Cleanup ...

func NewCleanup added in v1.0.9

func NewCleanup(log *xlog.Log, scatter *backend.Scatter, router *router.Router, spanner *Spanner) *Cleanup

NewCleanup -- creates new Cleanup handler.

func (*Cleanup) Cleanup added in v1.0.9

func (c *Cleanup) Cleanup() (*sqltypes.Result, error)

Cleanup used to find and cleanup the old data.

type DiskCheck

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

DiskCheck tuple.

func NewDiskCheck

func NewDiskCheck(log *xlog.Log, dir string) *DiskCheck

NewDiskCheck creates the DiskCheck tuple.

func (*DiskCheck) Close

func (dc *DiskCheck) Close()

Close used to close the disk check goroutine.

func (*DiskCheck) HighWater

func (dc *DiskCheck) HighWater() bool

HighWater returns the highwater mark. If true there is no space left on device.

func (*DiskCheck) Init

func (dc *DiskCheck) Init() error

Init used to init disk check goroutine.

type IP

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

IP tuple.

type IPTable

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

IPTable tuple.

func NewIPTable

func NewIPTable(log *xlog.Log, conf *config.ProxyConfig) *IPTable

NewIPTable creates a new IPTable.

func (*IPTable) Add

func (ipt *IPTable) Add(ip string) error

Add used to add an ip to iptable.

func (*IPTable) Check

func (ipt *IPTable) Check(address string) bool

Check used to check whether the ip is in ip table or not.

func (*IPTable) Refresh

func (ipt *IPTable) Refresh() error

Refresh used to refresh the table.

func (*IPTable) Remove

func (ipt *IPTable) Remove(ip string)

Remove used to remove a ip from table.

type Manager added in v1.0.6

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

func NewManager added in v1.0.6

func NewManager(log *xlog.Log, sessions *Sessions, conf *config.ProxyConfig) *Manager

NewManager creates new Manager.

func (*Manager) Close added in v1.0.6

func (mgr *Manager) Close()

Close used to close the goroutine.

func (*Manager) Init added in v1.0.6

func (mgr *Manager) Init() error

Init used to init manager goroutine.

type Proxy

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

Proxy tuple.

func MockProxy

func MockProxy(log *xlog.Log) (*fakedb.DB, *Proxy, func())

MockProxy mocks a proxy.

func MockProxy1

func MockProxy1(log *xlog.Log, conf *config.Config) (*fakedb.DB, *Proxy, func())

MockProxy1 mocks the proxy with config.

func MockProxyPrivilegeN added in v1.0.6

func MockProxyPrivilegeN(log *xlog.Log, conf *config.Config) (*fakedb.DB, *Proxy, func())

MockProxyPrivilegeN mocks the proxy with Privilege N.

func MockProxyPrivilegeNotSuper added in v1.0.6

func MockProxyPrivilegeNotSuper(log *xlog.Log, conf *config.Config) (*fakedb.DB, *Proxy, func())

MockProxyPrivilegeNotSuper mocks the proxy Not Super Privilege.

func MockProxyPrivilegeUsers added in v1.0.6

func MockProxyPrivilegeUsers(log *xlog.Log, conf *config.Config) (*fakedb.DB, *Proxy, func())

MockProxyPrivilegeUsers mocks the proxy with multipe users.

func NewProxy

func NewProxy(log *xlog.Log, path string, serverVersion string, conf *config.Config) *Proxy

NewProxy creates new proxy.

func (*Proxy) Address

func (p *Proxy) Address() string

Address returns the proxy endpoint.

func (*Proxy) Config

func (p *Proxy) Config() *config.Config

Config returns the config.

func (*Proxy) FlushConfig

func (p *Proxy) FlushConfig() error

FlushConfig used to flush the config to disk.

func (*Proxy) IPTable

func (p *Proxy) IPTable() *IPTable

IPTable returns the ip table.

func (*Proxy) PeerAddress

func (p *Proxy) PeerAddress() string

PeerAddress returns the peer address.

func (*Proxy) Plugins added in v1.0.9

func (p *Proxy) Plugins() *plugins.Plugin

Plugins return the plugins.

func (*Proxy) Router

func (p *Proxy) Router() *router.Router

Router returns the router.

func (*Proxy) Scatter

func (p *Proxy) Scatter() *backend.Scatter

Scatter returns the scatter.

func (*Proxy) Sessions

func (p *Proxy) Sessions() *Sessions

Sessions returns the sessions.

func (*Proxy) SetAllowIP

func (p *Proxy) SetAllowIP(ips []string)

SetAllowIP used to set allow ips.

func (*Proxy) SetAuditMode

func (p *Proxy) SetAuditMode(mode string)

SetAuditMode used to set the mode of audit.

func (*Proxy) SetAutocommitFalseIsTxn added in v1.0.8

func (p *Proxy) SetAutocommitFalseIsTxn(enable bool)

SetAutocommitFalseIsTxn used to set autocommitFalseIsTxn to true or false.

func (*Proxy) SetBlocks added in v1.0.9

func (p *Proxy) SetBlocks(blocks int)

SetBlocks used to set router blocks.

func (*Proxy) SetDDLTimeout

func (p *Proxy) SetDDLTimeout(timeout int)

SetDDLTimeout used to set the ddl timeout.

func (*Proxy) SetLoadBalance added in v1.1.1

func (p *Proxy) SetLoadBalance(val int)

SetLoadBalance used to set loadbalance.

func (*Proxy) SetLongQueryTime added in v1.0.1

func (p *Proxy) SetLongQueryTime(longQueryTime int)

SetLongQueryTime Set long Query Time used to set long query time.

func (*Proxy) SetLowerCaseTableNames added in v1.1.4

func (p *Proxy) SetLowerCaseTableNames(lowerCase int)

SetLowerCaseTableNames used to set LowerCaseTableNames to false or true.

func (*Proxy) SetMaxConnections

func (p *Proxy) SetMaxConnections(connections int)

SetMaxConnections used to set the max connections.

func (*Proxy) SetMaxJoinRows added in v1.0.7

func (p *Proxy) SetMaxJoinRows(size int)

SetMaxJoinRows used to set the max result size.

func (*Proxy) SetMaxResultSize

func (p *Proxy) SetMaxResultSize(size int)

SetMaxResultSize used to set the max result size.

func (*Proxy) SetQueryTimeout

func (p *Proxy) SetQueryTimeout(timeout int)

SetQueryTimeout used to set query timeout.

func (*Proxy) SetReadOnly

func (p *Proxy) SetReadOnly(val bool)

SetReadOnly used to enable/disable readonly.

func (*Proxy) SetStreamBufferSize added in v1.0.3

func (p *Proxy) SetStreamBufferSize(streamBufferSize int)

SetStreamBufferSize used to set the streamBufferSize.

func (*Proxy) SetThrottle

func (p *Proxy) SetThrottle(val int)

SetThrottle used to set the throttle.

func (*Proxy) SetTwoPC

func (p *Proxy) SetTwoPC(enable bool)

SetTwoPC used to set twopc to enable or disable.

func (*Proxy) Spanner

func (p *Proxy) Spanner() *Spanner

Spanner returns the spanner.

func (*Proxy) Start

func (p *Proxy) Start()

Start used to start the proxy.

func (*Proxy) Stop

func (p *Proxy) Stop()

Stop used to stop the proxy.

func (*Proxy) Syncer

func (p *Proxy) Syncer() *syncer.Syncer

Syncer returns the syncer.

type Rebalance added in v1.1.2

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

Rebalance ...

func NewRebalance added in v1.1.2

func NewRebalance(log *xlog.Log, scatter *backend.Scatter, router *router.Router, spanner *Spanner, conf *config.Config, plugins *plugins.Plugin) *Rebalance

NewRebalance -- creates new Rebalance handler.

func (*Rebalance) Rebalance added in v1.1.2

func (r *Rebalance) Rebalance() (*sqltypes.Result, error)

Rebalance used to Rebalance.

type Reshard added in v1.0.8

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

Reshard ...

func NewReshard added in v1.0.8

func NewReshard(log *xlog.Log, scatter *backend.Scatter, router *router.Router,
	spanner *Spanner, user string) *Reshard

NewReshard ...

func (*Reshard) CheckReshardDBTable added in v1.0.8

func (reshard *Reshard) CheckReshardDBTable(db, singleTable, dstDB, dstTable string) (bool, error)

CheckReshardDBTable check the database and table.

func (*Reshard) IsSingleTable added in v1.0.8

func (reshard *Reshard) IsSingleTable(db, singleTable string) (bool, error)

IsSingleTable check the table is Single or not.

func (*Reshard) ReShardTable added in v1.0.8

func (reshard *Reshard) ReShardTable(db, singleTable, dstDB, dstTable string) (*sqltypes.Result, error)

ReShardTable just reshard single table to the sharding table now.

func (*Reshard) SetHandle added in v1.0.8

func (reshard *Reshard) SetHandle(r ReshardHandle)

SetHandle set the handle

func (*Reshard) SetShiftProcessBar added in v1.0.8

func (reshard *Reshard) SetShiftProcessBar(finished int)

SetShiftProcessBar set the Shift Process Bar.

func (*Reshard) SetShiftStatus added in v1.0.8

func (reshard *Reshard) SetShiftStatus(err error)

SetShiftStatus set the shift status.

func (*Reshard) ShiftProcess added in v1.0.8

func (reshard *Reshard) ShiftProcess() error

ShiftProcess is call the shift tool cmd.

func (*Reshard) ShiftProcessBar added in v1.0.8

func (reshard *Reshard) ShiftProcessBar() int

ShiftProcessBar about status of the Shift Process Bar.

func (*Reshard) ShiftStatus added in v1.0.8

func (reshard *Reshard) ShiftStatus() error

ShiftStatus about shift status.

type ReshardHandle added in v1.0.8

type ReshardHandle interface {
	ShiftProcess() error
}

ReshardHandle ...

type SessionInfo

type SessionInfo struct {
	ID           uint32
	User         string
	Host         string
	DB           string
	Command      string
	Time         uint32
	State        string
	Info         string
	RowsSent     uint64
	RowsExamined uint64
}

SessionInfo tuple.

type Sessions

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

Sessions tuple.

func NewSessions

func NewSessions(log *xlog.Log) *Sessions

NewSessions creates new session.

func (*Sessions) Add

func (ss *Sessions) Add(s *driver.Session)

Add used to add the session to map when session created.

func (*Sessions) Close

func (ss *Sessions) Close()

Close used to close all sessions.

func (*Sessions) Kill

func (ss *Sessions) Kill(id uint32, reason string)

Kill used to kill a live session. 1. remove from sessions list. 2. close the session from the server side. 3. abort the session's txn.

func (*Sessions) MultiStmtTxnBinding added in v1.0.4

func (ss *Sessions) MultiStmtTxnBinding(s *driver.Session, txn backend.Transaction, node sqlparser.Statement, query string)

MultiStmtTxnBinding used to bind txn, node, query to the session

func (*Sessions) MultiStmtTxnUnBinding added in v1.0.4

func (ss *Sessions) MultiStmtTxnUnBinding(s *driver.Session, isEnd bool)

MultiStmtTxnUnBinding used to set transaction by isEnd

func (*Sessions) Reaches

func (ss *Sessions) Reaches(quota int) bool

Reaches used to check whether the sessions count reaches(>=) the quota.

func (*Sessions) Remove

func (ss *Sessions) Remove(s *driver.Session)

Remove used to remove the session from the map when session exit.

func (*Sessions) Snapshot

func (ss *Sessions) Snapshot() []SessionInfo

Snapshot returns all session info.

func (*Sessions) SnapshotTxn added in v1.0.6

func (ss *Sessions) SnapshotTxn() []SessionInfo

SnapshotTxn returns all sessions info in transaction.

func (*Sessions) SnapshotUser added in v1.0.6

func (ss *Sessions) SnapshotUser(user string) []SessionInfo

Snapshot returns all session info about the user.

func (*Sessions) TxnBinding

func (ss *Sessions) TxnBinding(s *driver.Session, txn backend.Transaction, node sqlparser.Statement, query string)

TxnBinding used to bind txn to the session.

func (*Sessions) TxnUnBinding

func (ss *Sessions) TxnUnBinding(s *driver.Session)

TxnUnBinding used to set transaction and node to nil.

type Spanner

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

Spanner tuple.

func NewSpanner

func NewSpanner(log *xlog.Log, conf *config.Config,
	iptable *IPTable, router *router.Router, scatter *backend.Scatter, sessions *Sessions, audit *audit.Audit, throttle *xbase.Throttle, plugins *plugins.Plugin, serverVersion string) *Spanner

NewSpanner creates a new spanner.

func (*Spanner) AuthCheck

func (spanner *Spanner) AuthCheck(s *driver.Session) error

AuthCheck impl.

func (*Spanner) Close

func (spanner *Spanner) Close() error

Close used to close spanner.

func (*Spanner) ComInitDB

func (spanner *Spanner) ComInitDB(session *driver.Session, database string) error

ComInitDB impl. Here, we will send a fake query 'SELECT 1' to the backend and check the 'USE DB'.

func (*Spanner) ComQuery

func (spanner *Spanner) ComQuery(session *driver.Session, query string, bindVariables map[string]*querypb.BindVariable, callback func(qr *sqltypes.Result) error) error

ComQuery impl. Supports statements are: 1. DDL 2. DML 3. USE DB: MySQL client use 'database' won't pass here, FIXME.

func (*Spanner) ExecuteBegin added in v1.0.4

func (spanner *Spanner) ExecuteBegin(session *driver.Session, query string, node sqlparser.Statement) (*sqltypes.Result, error)

ExecuteBegin used to execute "start transaction" or "begin".

func (*Spanner) ExecuteCommit added in v1.0.4

func (spanner *Spanner) ExecuteCommit(session *driver.Session, query string, node sqlparser.Statement) (*sqltypes.Result, error)

ExecuteCommit used to execute multiple-statement transaction: "commit"

func (*Spanner) ExecuteDDL

func (spanner *Spanner) ExecuteDDL(session *driver.Session, database string, query string, node sqlparser.Statement) (*sqltypes.Result, error)

ExecuteDDL used to execute ddl querys to the shards with DDLTimeout limits, used for create/drop index long time operation.

func (*Spanner) ExecuteDML added in v1.0.4

func (spanner *Spanner) ExecuteDML(session *driver.Session, database string, query string, node sqlparser.Statement) (*sqltypes.Result, error)

ExecuteDML used to execute some DML querys to shards.

func (*Spanner) ExecuteMultiStmtsInTxn added in v1.0.4

func (spanner *Spanner) ExecuteMultiStmtsInTxn(session *driver.Session, database string, query string, node sqlparser.Statement) (*sqltypes.Result, error)

ExecuteMultiStmtsInTxn used to execute multiple statements in the transaction.

func (*Spanner) ExecuteNormal

func (spanner *Spanner) ExecuteNormal(session *driver.Session, database string, query string, node sqlparser.Statement) (*sqltypes.Result, error)

ExecuteNormal used to execute non-2pc querys to shards with QueryTimeout limits.

func (*Spanner) ExecuteOnThisBackend

func (spanner *Spanner) ExecuteOnThisBackend(backend string, query string) (*sqltypes.Result, error)

ExecuteOnThisBackend used to executye query on the backend whitout planner.

func (*Spanner) ExecuteRollback added in v1.0.4

func (spanner *Spanner) ExecuteRollback(session *driver.Session, query string, node sqlparser.Statement) (*sqltypes.Result, error)

ExecuteRollback used to execute multiple-statement transaction sql:"rollback"

func (*Spanner) ExecuteScatter

func (spanner *Spanner) ExecuteScatter(query string) (*sqltypes.Result, error)

ExecuteScatter used to execute query on all shards without planner.

func (*Spanner) ExecuteSingle

func (spanner *Spanner) ExecuteSingle(query string) (*sqltypes.Result, error)

ExecuteSingle used to execute query on one shard without planner. The query must contain the database, such as db.table.

func (*Spanner) ExecuteSingleStmtTxnTwoPC added in v1.0.4

func (spanner *Spanner) ExecuteSingleStmtTxnTwoPC(session *driver.Session, database string, query string, node sqlparser.Statement) (*sqltypes.Result, error)

ExecuteSingleStmtTxnTwoPC used to execute single statement transaction with 2pc commit.

func (*Spanner) ExecuteStreamFetch

func (spanner *Spanner) ExecuteStreamFetch(session *driver.Session, database string, query string, node sqlparser.Statement, callback func(qr *sqltypes.Result) error) error

ExecuteStreamFetch used to execute a stream fetch query.

func (*Spanner) Init

func (spanner *Spanner) Init() error

Init used to init the async worker.

func (*Spanner) IsAdminCmd added in v1.0.9

func (spanner *Spanner) IsAdminCmd(node sqlparser.Statement) bool

IsAdminCmd returns the Admin query or not. Some of admin commands are prohibited when radon is read-only.

func (*Spanner) IsDDL

func (spanner *Spanner) IsDDL(node sqlparser.Statement) bool

IsDDL returns the DDL query or not.

func (*Spanner) IsDML

func (spanner *Spanner) IsDML(node sqlparser.Statement) bool

IsDML returns the DML query or not.

func (*Spanner) IsDMLWrite

func (spanner *Spanner) IsDMLWrite(node sqlparser.Statement) bool

IsDMLWrite returns the DML write or not.

func (*Spanner) NewSession

func (spanner *Spanner) NewSession(s *driver.Session)

NewSession impl.

func (*Spanner) ReadOnly

func (spanner *Spanner) ReadOnly() bool

ReadOnly returns the readonly or not.

func (*Spanner) ServerVersion added in v1.0.6

func (spanner *Spanner) ServerVersion() string

ServerVersion impl -- returns server version of Radon when greeting.

func (*Spanner) SessionCheck

func (spanner *Spanner) SessionCheck(s *driver.Session) error

SessionCheck used to check authentication.

func (*Spanner) SessionClosed

func (spanner *Spanner) SessionClosed(s *driver.Session)

SessionClosed impl.

func (*Spanner) SessionDec added in v1.0.1

func (spanner *Spanner) SessionDec(s *driver.Session)

SessionDec decrease client connection metrics.

func (*Spanner) SessionInc added in v1.0.1

func (spanner *Spanner) SessionInc(s *driver.Session)

SessionInc increase client connection metrics, it need the user is assigned

func (*Spanner) SetReadOnly

func (spanner *Spanner) SetReadOnly(val bool)

SetReadOnly used to set readonly.

func (*Spanner) SetServerVersion added in v1.0.8

func (spanner *Spanner) SetServerVersion()

SetServerVersion used to set serverVersion.

Jump to

Keyboard shortcuts

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