Documentation ¶
Index ¶
- type DDLItem
- type ShardingMeta
- func (meta *ShardingMeta) ActiveDDLFirstLocation() (binlog.Location, error)
- func (meta *ShardingMeta) ActiveIdx() int
- func (meta *ShardingMeta) AddItem(item *DDLItem) (active bool, err error)
- func (meta *ShardingMeta) CheckAndUpdate(logger log.Logger, targetID string, schemaMap map[string]string, ...) ([]string, [][]interface{}, 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, flavor string) error
- type ShardingSequence
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DDLItem ¶
type DDLItem struct { FirstLocation binlog.Location `json:"-"` // 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 // just used for json's marshal and unmarshal, because gtid set in FirstLocation is interface, // can't be marshal and unmarshal FirstPosition mysql.Position `json:"first-position"` FirstGTIDSet string `json:"first-gtid-set"` }
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, enableGTID bool) *ShardingMeta
NewShardingMeta creates a new ShardingMeta.
func (*ShardingMeta) ActiveDDLFirstLocation ¶
func (meta *ShardingMeta) ActiveDDLFirstLocation() (binlog.Location, error)
ActiveDDLFirstLocation 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, which means len(source.Items) > len(global.Items), 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) CheckAndUpdate ¶
func (meta *ShardingMeta) CheckAndUpdate(logger log.Logger, targetID string, schemaMap map[string]string, tablesMap map[string]map[string]string) ([]string, [][]interface{}, error)
CheckAndUpdate check and fix schema and table names for all the sharding groups.
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 ¶
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, flavor string) 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.