Documentation ¶
Index ¶
- Constants
- type DDLItem
- type ShardingMeta
- func (meta *ShardingMeta) ActiveDDLFirstPos() (mysql.Position, error)
- func (meta *ShardingMeta) ActiveIdx() int
- func (meta *ShardingMeta) AddItem(item *DDLItem) (active bool, err error)
- func (meta *ShardingMeta) FlushData(sourceID, tableID string) ([]string, [][]interface{})
- func (meta *ShardingMeta) GetActiveDDLItem(tableSource string) *DDLItem
- func (meta *ShardingMeta) GetGlobalActiveDDL() *DDLItem
- func (meta *ShardingMeta) GetGlobalItems() []*DDLItem
- func (meta *ShardingMeta) InSequenceSharding() bool
- func (meta *ShardingMeta) Reinitialize()
- func (meta *ShardingMeta) ResolveShardingDDL() bool
- func (meta *ShardingMeta) RestoreFromData(sourceTableID string, activeIdx int, isGlobal bool, data []byte) error
- type ShardingSequence
Constants ¶
const (
// MetaTableFormat is used in meta table name constructor
MetaTableFormat = "%s_syncer_sharding_meta"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DDLItem ¶
type DDLItem struct { FirstPos mysql.Position `json:"first-pos"` // first DDL's binlog Pos, not the End_log_pos of the event DDLs []string `json:"ddls"` // DDLs, these ddls are in the same QueryEvent Source string `json:"source"` // source table ID }
DDLItem records ddl information used in sharding sequence organization
func NewDDLItem ¶
NewDDLItem creates a new DDLItem
type ShardingMeta ¶
type ShardingMeta struct {
// contains filtered or unexported fields
}
ShardingMeta stores sharding ddl sequence including global sequence and each source's own sequence NOTE: sharding meta is not thread safe, it must be used in thread safe context
func NewShardingMeta ¶
func NewShardingMeta(schema, table string) *ShardingMeta
NewShardingMeta creates a new ShardingMeta
func (*ShardingMeta) ActiveDDLFirstPos ¶
func (meta *ShardingMeta) ActiveDDLFirstPos() (mysql.Position, error)
ActiveDDLFirstPos returns the first binlog position of active DDL
func (*ShardingMeta) ActiveIdx ¶
func (meta *ShardingMeta) ActiveIdx() int
ActiveIdx returns the activeIdx of sharding meta
func (*ShardingMeta) AddItem ¶
func (meta *ShardingMeta) AddItem(item *DDLItem) (active bool, err error)
AddItem adds a new coming DDLItem into ShardingMeta 1. if DDLItem already exists in source sequence, check whether it is active DDL only 2. add the DDLItem into its related source sequence 3. if it is a new DDL in global sequence, add it into global sequence 4. check the source sequence is the prefix-sequence of global sequence, if not, return an error returns:
active: whether the DDL will be processed in this round
func (*ShardingMeta) FlushData ¶
func (meta *ShardingMeta) FlushData(sourceID, tableID string) ([]string, [][]interface{})
FlushData returns sharding meta flush SQL and args
func (*ShardingMeta) GetActiveDDLItem ¶
func (meta *ShardingMeta) GetActiveDDLItem(tableSource string) *DDLItem
GetActiveDDLItem returns the source table's active DDLItem if in DDL unsynced procedure, the active DDLItem means the syncing DDL if in re-sync procedure, the active DDLItem means the next syncing DDL in DDL syncing sequence, may be nil
func (*ShardingMeta) GetGlobalActiveDDL ¶
func (meta *ShardingMeta) GetGlobalActiveDDL() *DDLItem
GetGlobalActiveDDL returns activeDDL in global sequence
func (*ShardingMeta) GetGlobalItems ¶
func (meta *ShardingMeta) GetGlobalItems() []*DDLItem
GetGlobalItems returns global DDLItems
func (*ShardingMeta) InSequenceSharding ¶
func (meta *ShardingMeta) InSequenceSharding() bool
InSequenceSharding returns whether in sequence sharding
func (*ShardingMeta) Reinitialize ¶ added in v1.0.6
func (meta *ShardingMeta) Reinitialize()
Reinitialize reinitialize the shardingmeta
func (*ShardingMeta) ResolveShardingDDL ¶
func (meta *ShardingMeta) ResolveShardingDDL() bool
ResolveShardingDDL resolves one sharding DDL and increase activeIdx if activeIdx equals to the length of global sharding sequence, it means all sharding DDL in this ShardingMeta sequence is resolved and will reinitialize the ShardingMeta, return true if all DDLs are resolved.
func (*ShardingMeta) RestoreFromData ¶
func (meta *ShardingMeta) RestoreFromData(sourceTableID string, activeIdx int, isGlobal bool, data []byte) error
RestoreFromData restores ShardingMeta from given data
type ShardingSequence ¶
type ShardingSequence struct {
Items []*DDLItem `json:"items"`
}
ShardingSequence records a list of DDLItem
func (*ShardingSequence) IsPrefixSequence ¶
func (seq *ShardingSequence) IsPrefixSequence(other *ShardingSequence) bool
IsPrefixSequence checks whether a ShardingSequence is the prefix sequence of other.
func (*ShardingSequence) String ¶
func (seq *ShardingSequence) String() string
String returns the ShardingSequence's json string