gh-ost/go/base/context.go

52 lines
1.1 KiB
Go
Raw Normal View History

2016-04-01 11:36:56 +00:00
/*
Copyright 2016 GitHub Inc.
See https://github.com/github/gh-osc/blob/master/LICENSE
*/
package base
import ()
type RowsEstimateMethod string
const (
TableStatusRowsEstimate RowsEstimateMethod = "TableStatusRowsEstimate"
ExplainRowsEstimate = "ExplainRowsEstimate"
CountRowsEstimate = "CountRowsEstimate"
)
2016-04-01 11:36:56 +00:00
type MigrationContext struct {
DatabaseName string
OriginalTableName string
GhostTableName string
AlterStatement string
TableEngine string
CountTableRows bool
RowsEstimate int64
UsedRowsEstimateMethod RowsEstimateMethod
ChunkSize int
OriginalBinlogFormat string
OriginalBinlogRowImage string
2016-04-01 11:36:56 +00:00
}
2016-04-01 14:05:44 +00:00
var context *MigrationContext
func init() {
context = newMigrationContext()
}
2016-04-01 14:05:44 +00:00
func newMigrationContext() *MigrationContext {
return &MigrationContext{
ChunkSize: 1000,
}
}
func GetMigrationContext() *MigrationContext {
return context
}
// RequiresBinlogFormatChange
func (this *MigrationContext) RequiresBinlogFormatChange() bool {
return this.OriginalBinlogFormat != "ROW"
2016-04-01 14:05:44 +00:00
}