Documentation ¶
Index ¶
- Constants
- Variables
- func NewBoltdbStorage(path string) (*boltdbStorage, error)
- func NewMysqlStorage(addr string, user string, password string, database string) (*mysqlStorage, error)
- type ColumnDef
- type IndexType
- type Iterator
- type SchemaStorage
- type SchemaTracker
- func (o *SchemaTracker) Exec(db string, statement string) error
- func (o *SchemaTracker) ExecAndPersist(db string, statement string, pos mysql.Position) error
- func (o *SchemaTracker) GetDatabases() []string
- func (o *SchemaTracker) GetTableDef(db string, table string) (*TableDef, error)
- func (o *SchemaTracker) GetTables(db string) ([]string, error)
- func (o *SchemaTracker) IsDdl(sql string) (bool, error)
- func (o *SchemaTracker) Persist(pos mysql.Position) error
- func (o *SchemaTracker) Reset() error
- type TableDef
- type TrackerConfig
Constants ¶
View Source
const ( StorageType_Boltdb string = "boltdb" StorageType_Mysql string = "mysql" )
View Source
const ( TypeDecimal byte = 0 TypeTiny byte = 1 TypeShort byte = 2 TypeLong byte = 3 TypeFloat byte = 4 TypeDouble byte = 5 TypeNull byte = 6 TypeTimestamp byte = 7 TypeLonglong byte = 8 TypeInt24 byte = 9 TypeDate byte = 10 /* Original name was TypeTime, renamed to Duration to resolve the conflict with Go type Time.*/ TypeDuration byte = 11 TypeDatetime byte = 12 TypeYear byte = 13 TypeNewDate byte = 14 TypeVarchar byte = 15 TypeBit byte = 16 TypeJSON byte = 0xf5 TypeNewDecimal byte = 0xf6 TypeEnum byte = 0xf7 TypeSet byte = 0xf8 TypeTinyBlob byte = 0xf9 TypeMediumBlob byte = 0xfa TypeLongBlob byte = 0xfb TypeBlob byte = 0xfc TypeVarString byte = 0xfd TypeString byte = 0xfe TypeGeometry byte = 0xff )
MySQL type information.
View Source
const ( IndexType_NONE IndexType = "" IndexType_PRI = "PRI" IndexType_UNI = "UNI" IndexType_MUL = "MUL" )
Variables ¶
View Source
var HAHealthCheckSchema = "mysql.ha_health_check"
Functions ¶
func NewBoltdbStorage ¶
Types ¶
type SchemaStorage ¶
type SchemaStorage interface { // SaveSnapshot will be called when schema tracker decides to save a snapshot SaveSnapshot(data []byte, pos mysql.Position) error // SaveSnapshot will be called when schema tracker decides to save a ddl statement SaveStatement(db string, statement string, pos mysql.Position) error // LoadLastSnapshot will be called when schema tracker need to restore snapshot, as base data LoadLastSnapshot() ([]byte, mysql.Position, error) // Reset will be called to get a empty storage Reset() error // StatementIterator return an iterator which can iterate all ddl statements after last snapshot StatementIterator() Iterator }
type SchemaTracker ¶
type SchemaTracker struct {
// contains filtered or unexported fields
}
func NewSchemaTracker ¶
func NewSchemaTracker(cfg *TrackerConfig) (*SchemaTracker, error)
New a schema tracker that can track DDL statements, making a schema mirror.
func (*SchemaTracker) Exec ¶
func (o *SchemaTracker) Exec(db string, statement string) error
Exec ddl statement, but don't persistent the schema info
func (*SchemaTracker) ExecAndPersist ¶
Exec ddl statement, and persistent the schema info into storage
func (*SchemaTracker) GetDatabases ¶
func (o *SchemaTracker) GetDatabases() []string
Get all db names, like 'SHOW DATABASES'
func (*SchemaTracker) GetTableDef ¶
func (o *SchemaTracker) GetTableDef(db string, table string) (*TableDef, error)
func (*SchemaTracker) GetTables ¶
func (o *SchemaTracker) GetTables(db string) ([]string, error)
Get all table names in specified db, like 'SHOW TABLES'
func (*SchemaTracker) IsDdl ¶
func (o *SchemaTracker) IsDdl(sql string) (bool, error)
Check whether the SQL statement is DDL, means not DML/DCL
func (*SchemaTracker) Persist ¶
func (o *SchemaTracker) Persist(pos mysql.Position) error
Persistent the schema info into storage. Before Persist is called, must ensure the binlog DML events previous is synced.
func (*SchemaTracker) Reset ¶
func (o *SchemaTracker) Reset() error
Reset executor's schema info and storage
type TrackerConfig ¶
type TrackerConfig struct { // The charset_set_server of source mysql, we need // this charset to handle ddl statement CharsetServer string // Storage type to store schema data, may be boltdb or mysql Storage string // Boltdb file path to store data Dir string // MySQL info to connect Addr string User string Password string Database string }
Click to show internal directories.
Click to hide internal directories.