Documentation
¶
Index ¶
- Constants
- func CheckCreateTable(ddl *sqlparser.DDL) error
- func MockConfigMax16() *config.Config
- func MockDefaultConfig() *config.Config
- type BackupRelay
- func (br *BackupRelay) Close()
- func (br *BackupRelay) Init() error
- func (br *BackupRelay) MaxWorkers() int32
- func (br *BackupRelay) ParallelType() int32
- func (br *BackupRelay) ParallelWorkers() int32
- func (br *BackupRelay) RelayBinlog() string
- func (br *BackupRelay) RelayCounts() int64
- func (br *BackupRelay) RelayGTID() int64
- func (br *BackupRelay) RelayRates() string
- func (br *BackupRelay) RelayStatus() bool
- func (br *BackupRelay) ResetRelayWorker(gtid int64)
- func (br *BackupRelay) RestartGTID() int64
- func (br *BackupRelay) SetMaxWorkers(n int32)
- func (br *BackupRelay) SetParallelType(n int32)
- func (br *BackupRelay) StartRelayWorker()
- func (br *BackupRelay) StopRelayWorker()
- type DiskCheck
- type IP
- type IPTable
- type Proxy
- func MockProxy(log *xlog.Log) (*fakedb.DB, *Proxy, func())
- func MockProxy1(log *xlog.Log, conf *config.Config) (*fakedb.DB, *Proxy, func())
- func MockProxy2(log *xlog.Log, conf *config.Config) (*fakedb.DB, *Proxy, func())
- func MockProxyWithBackup(log *xlog.Log) (*fakedb.DB, *Proxy, func())
- func NewProxy(log *xlog.Log, path string, conf *config.Config) *Proxy
- func (p *Proxy) Address() string
- func (p *Proxy) Binlog() *binlog.Binlog
- func (p *Proxy) Config() *config.Config
- func (p *Proxy) FlushConfig() error
- func (p *Proxy) IPTable() *IPTable
- func (p *Proxy) PeerAddress() string
- func (p *Proxy) Router() *router.Router
- func (p *Proxy) Scatter() *backend.Scatter
- func (p *Proxy) Sessions() *Sessions
- func (p *Proxy) SetAllowIP(ips []string)
- func (p *Proxy) SetAuditMode(mode string)
- func (p *Proxy) SetDDLTimeout(timeout int)
- func (p *Proxy) SetLongQueryTime(longQueryTime int)
- func (p *Proxy) SetMaxConnections(connections int)
- func (p *Proxy) SetMaxResultSize(size int)
- func (p *Proxy) SetQueryTimeout(timeout int)
- func (p *Proxy) SetReadOnly(val bool)
- func (p *Proxy) SetThrottle(val int)
- func (p *Proxy) SetTwoPC(enable bool)
- func (p *Proxy) Spanner() *Spanner
- func (p *Proxy) Start()
- func (p *Proxy) Stop()
- func (p *Proxy) Syncer() *syncer.Syncer
- type SessionInfo
- type Sessions
- func (ss *Sessions) Add(s *driver.Session)
- func (ss *Sessions) Close()
- func (ss *Sessions) Kill(id uint32, reason string)
- func (ss *Sessions) Reaches(quota int) bool
- func (ss *Sessions) Remove(s *driver.Session)
- func (ss *Sessions) Snapshot() []SessionInfo
- func (ss *Sessions) TxnBinding(s *driver.Session, txn backend.Transaction, node sqlparser.Statement, ...)
- func (ss *Sessions) TxnUnBinding(s *driver.Session)
- type Spanner
- func (spanner *Spanner) AuthCheck(s *driver.Session) error
- func (spanner *Spanner) BackupRelay() *BackupRelay
- func (spanner *Spanner) Close() error
- func (spanner *Spanner) ComInitDB(session *driver.Session, database string) error
- func (spanner *Spanner) ComQuery(session *driver.Session, query string, ...) error
- func (spanner *Spanner) Execute(session *driver.Session, database string, query string, ...) (*sqltypes.Result, error)
- func (spanner *Spanner) ExecuteDDL(session *driver.Session, database string, query string, ...) (*sqltypes.Result, error)
- func (spanner *Spanner) ExecuteNormal(session *driver.Session, database string, query string, ...) (*sqltypes.Result, error)
- func (spanner *Spanner) ExecuteOnBackup(database string, query string) (*sqltypes.Result, error)
- func (spanner *Spanner) ExecuteOnThisBackend(backend string, query string) (*sqltypes.Result, error)
- func (spanner *Spanner) ExecuteScatter(query string) (*sqltypes.Result, error)
- func (spanner *Spanner) ExecuteSingle(query string) (*sqltypes.Result, error)
- func (spanner *Spanner) ExecuteStreamFetch(session *driver.Session, database string, query string, ...) error
- func (spanner *Spanner) ExecuteTwoPC(session *driver.Session, database string, query string, ...) (*sqltypes.Result, error)
- func (spanner *Spanner) Init() error
- func (spanner *Spanner) IsDDL(node sqlparser.Statement) bool
- func (spanner *Spanner) IsDML(node sqlparser.Statement) bool
- func (spanner *Spanner) IsDMLWrite(node sqlparser.Statement) bool
- func (spanner *Spanner) NewSession(s *driver.Session)
- func (spanner *Spanner) ReadOnly() bool
- func (spanner *Spanner) SessionCheck(s *driver.Session) error
- func (spanner *Spanner) SessionClosed(s *driver.Session)
- func (spanner *Spanner) SessionDec(s *driver.Session)
- func (spanner *Spanner) SessionInc(s *driver.Session)
- func (spanner *Spanner) SetReadOnly(val bool)
Constants ¶
const ( // R enum. R mode = iota // W enum. W )
Variables ¶
This section is empty.
Functions ¶
func CheckCreateTable ¶
CheckCreateTable used to check the CRERATE TABLE statement.
func MockConfigMax16 ¶
MockConfigMax16 mocks the config with MaxConnections=16.
Types ¶
type BackupRelay ¶
type BackupRelay struct {
// contains filtered or unexported fields
}
BackupRelay tuple.
func NewBackupRelay ¶
func NewBackupRelay(log *xlog.Log, conf *config.BinlogConfig, spanner *Spanner) *BackupRelay
NewBackupRelay creates new BackupRelay tuple.
func (*BackupRelay) Close ¶
func (br *BackupRelay) Close()
Close used to close all the backgroud workers.
func (*BackupRelay) MaxWorkers ¶
func (br *BackupRelay) MaxWorkers() int32
MaxWorkers returns the max parallel worker numbers.
func (*BackupRelay) ParallelType ¶
func (br *BackupRelay) ParallelType() int32
ParallelType returns the type of parallel.
func (*BackupRelay) ParallelWorkers ¶
func (br *BackupRelay) ParallelWorkers() int32
ParallelWorkers returns the number of the parallel workers.
func (*BackupRelay) RelayBinlog ¶
func (br *BackupRelay) RelayBinlog() string
RelayBinlog returns the current relay binlog name.
func (*BackupRelay) RelayCounts ¶
func (br *BackupRelay) RelayCounts() int64
RelayCounts returns the counts have relayed.
func (*BackupRelay) RelayGTID ¶
func (br *BackupRelay) RelayGTID() int64
RelayGTID returns the current relay GTID.
func (*BackupRelay) RelayRates ¶
func (br *BackupRelay) RelayRates() string
RelayRates returns the relay rates.
func (*BackupRelay) RelayStatus ¶
func (br *BackupRelay) RelayStatus() bool
RelayStatus returns the stop status.
func (*BackupRelay) ResetRelayWorker ¶
func (br *BackupRelay) ResetRelayWorker(gtid int64)
ResetRelayWorker used to reset the relay gtid. Then the relay worker should relay from the new gtid point.
func (*BackupRelay) RestartGTID ¶
func (br *BackupRelay) RestartGTID() int64
RestartGTID returns the restart GTID of next relay.
func (*BackupRelay) SetMaxWorkers ¶
func (br *BackupRelay) SetMaxWorkers(n int32)
SetMaxWorkers used to set the limits number.
func (*BackupRelay) SetParallelType ¶
func (br *BackupRelay) SetParallelType(n int32)
SetParallelType used to set the parallel type.
func (*BackupRelay) StartRelayWorker ¶
func (br *BackupRelay) StartRelayWorker()
StartRelayWorker used to restart the relay worker.
func (*BackupRelay) StopRelayWorker ¶
func (br *BackupRelay) StopRelayWorker()
StopRelayWorker used to stop the relay worker.
type DiskCheck ¶
type DiskCheck struct {
// contains filtered or unexported fields
}
DiskCheck tuple.
func NewDiskCheck ¶
NewDiskCheck creates the DiskCheck tuple.
func (*DiskCheck) Close ¶
func (dc *DiskCheck) Close()
Close used to close the disk check goroutine.
func (*DiskCheck) HighWater ¶
HighWater returns the highwater mark. If true there is no space left on device.
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) Check ¶
Check used to check a whether the ip is in ip table or not.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy tuple.
func MockProxy ¶
MockProxy mocks a proxy.
func MockProxy1 ¶
MockProxy1 mocks the proxy with config.
func MockProxy2 ¶
MockProxy2 mocks the proxy with the conf.
func MockProxyWithBackup ¶
MockProxyWithBackup mocks the proxy with backup.
func NewProxy ¶
NewProxy creates new proxy.
func (*Proxy) FlushConfig ¶
FlushConfig used to flush the config to disk.
func (*Proxy) PeerAddress ¶
PeerAddress returns the peer address.
func (*Proxy) SetAllowIP ¶
SetAllowIP used to set allow ips.
func (*Proxy) SetAuditMode ¶
SetAuditMode used to set the mode of audit.
func (*Proxy) SetDDLTimeout ¶
SetDDLTimeout used to set the ddl timeout.
func (*Proxy) SetLongQueryTime ¶ added in v1.0.1
SetLongQueryTime Set long Query Time used to set long query time.
func (*Proxy) SetMaxConnections ¶
SetMaxConnections used to set the max connections.
func (*Proxy) SetMaxResultSize ¶
SetMaxResultSize used to set the max result size.
func (*Proxy) SetQueryTimeout ¶
SetQueryTimeout used to set query timeout.
func (*Proxy) SetReadOnly ¶
SetReadOnly used to enable/disable readonly.
func (*Proxy) SetThrottle ¶
SetThrottle used to set the throttle.
func (*Proxy) SetTwoPC ¶
SetTwoPC used to set twopc to enable or disable.
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 (*Sessions) Add ¶
Add used to add the session to map when session created.
func (*Sessions) Kill ¶
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) Reaches ¶
Reaches used to check whether the sessions count reaches(>=) the quota.
func (*Sessions) Remove ¶
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.
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, binlog *binlog.Binlog, sessions *Sessions, audit *audit.Audit, throttle *xbase.Throttle) *Spanner
NewSpanner creates a new spanner.
func (*Spanner) AuthCheck ¶
AuthCheck impl.
func (*Spanner) BackupRelay ¶
func (spanner *Spanner) BackupRelay() *BackupRelay
BackupRelay returns BackupRelay tuple.
func (*Spanner) ComInitDB ¶
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, callback func(qr *sqltypes.Result) error) error
ComQuery impl. Supports statements are: 1. DDL 2. DML 3. USE DB
func (*Spanner) Execute ¶
func (spanner *Spanner) Execute(session *driver.Session, database string, query string, node sqlparser.Statement) (*sqltypes.Result, error)
Execute used to execute querys to shards.
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) 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) ExecuteOnBackup ¶
ExecuteOnBackup used to executye query on the backup.
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) ExecuteScatter ¶
ExecuteScatter used to execute query on all shards without planner.
func (*Spanner) ExecuteSingle ¶
ExecuteSingle used to execute query on one shard without planner. The query must contain the database, such as db.table.
func (*Spanner) ExecuteStreamFetch ¶
func (spanner *Spanner) ExecuteStreamFetch(session *driver.Session, database string, query string, node sqlparser.Statement, callback func(qr *sqltypes.Result) error, streamBufferSize int) error
ExecuteStreamFetch used to execute a stream fetch query.
func (*Spanner) ExecuteTwoPC ¶
func (spanner *Spanner) ExecuteTwoPC(session *driver.Session, database string, query string, node sqlparser.Statement) (*sqltypes.Result, error)
ExecuteTwoPC allows multi-shards transactions with 2pc commit.
func (*Spanner) IsDDL ¶
IsDDL returns the DDL query or not.
func (*Spanner) IsDML ¶
IsDML returns the DML query or not.
func (*Spanner) IsDMLWrite ¶
IsDMLWrite returns the DML write or not.
func (*Spanner) ReadOnly ¶
ReadOnly returns the readonly or not.
func (*Spanner) SessionCheck ¶
SessionCheck used to check authentication.
func (*Spanner) SessionClosed ¶
SessionClosed impl.
func (*Spanner) SessionDec ¶ added in v1.0.1
SessionDec decrease client connection metrics.
func (*Spanner) SessionInc ¶ added in v1.0.1
SessionInc increase client connection metrics, it need the user is assigned