history

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHistory

func AddHistory(dbName string, SchemaName string, TableName string, Property HistoryProperty, ToServerIDList []int) (int, error)

func CheckWhere added in v1.2.2

func CheckWhere(dbName, SchemaName, TableName, Where string) error

func CheckWhere0 added in v1.2.2

func CheckWhere0(Uri string, SchemaName string, TableName string, Where string) error

func DBConnect

func DBConnect(uri string) mysql.MysqlConnection

func DelHistory

func DelHistory(dbName string, ID int) bool

func GetTablePriKeyMinAndMaxVal added in v1.2.2

func GetTablePriKeyMinAndMaxVal(db mysql.MysqlConnection, schema, table, PriKey, where string) (minId uint64, maxId uint64)

func KillHistory

func KillHistory(dbName string, ID int) error

func Start

func Start(dbName string, ID int) error

Types

type HisotryStatus

type HisotryStatus string
const (
	HISTORY_STATUS_ALL         HisotryStatus = "All"
	HISTORY_STATUS_CLOSE       HisotryStatus = "close"
	HISTORY_STATUS_RUNNING     HisotryStatus = "running"
	HISTORY_STATUS_OVER        HisotryStatus = "over"
	HISTORY_STATUS_HALFWAY     HisotryStatus = "halfway"
	HISTORY_STATUS_KILLED      HisotryStatus = "killed"
	HISTORY_STATUS_SELECT_OVER HisotryStatus = "selectOver" //拉取数据结束
)

type History

type History struct {
	sync.RWMutex
	ID         int
	DbName     string
	SchemaName string
	TableName  string
	Property   HistoryProperty
	Status     HisotryStatus
	NowStartI  uint64 //当前第几条数据
	ThreadPool []*ThreadStatus

	Fields             []TableStruct   `json:"-"`
	TableInfo          TableInfoStruct `json:"-"`
	Uri                string          `json:"-"`
	ToServerIDList     []int
	StartTime          string
	OverTime           string
	TablePriKeyMinId   uint64 // 假如主键是自增id的情况下 这个值是当前自增id最小值
	TablePriKeyMaxId   uint64 // 假如主键是自增id的情况下 这个值是当前自增id最大值
	TablePriKey        string // 主键字段
	TablePriArr        []*string
	ToServerList       []*server.ToServer
	ToServerTheadCount int16 // 实际正在运行的同步协程数
	//toServerTheadCountChan chan int16	// 同步协程 开始或者结束,都会往这个chan里 +1,-1写数据.用于计算是不是所有同步协程都已结束
	ToServerTheadGroup *sync.WaitGroup
	// contains filtered or unexported fields
}

func GetHistoryList

func GetHistoryList(dbName, SchemaName, TableName string, status HisotryStatus) []History

func (*History) GetNextSql added in v1.2.2

func (This *History) GetNextSql() (sql string, start uint64)

func (*History) InitToServer added in v1.2.2

func (This *History) InitToServer()

func (*History) Start

func (This *History) Start() error

func (*History) Stop

func (This *History) Stop() error

func (*History) SyncWaitToServerOver added in v1.2.2

func (This *History) SyncWaitToServerOver(n int)

type HistoryProperty

type HistoryProperty struct {
	ThreadNum      int    // 拉取数据协程数量,每个协程一个连接
	ThreadCountPer int    // 协程每次最多处理多少条数据
	Where          string // where 条件
	LimitOptimize  int8   // 是否自动分页优化, 1 采用 between 方式优化 0 不启动优化
	SyncThreadNum  int    // 同步协程数
}

type TableInfoStruct added in v1.2.2

type TableInfoStruct struct {
	TABLE_TYPE string
	ENGINE     string
	TABLE_ROWS uint64
}

func GetSchemaTableInfo added in v1.2.2

func GetSchemaTableInfo(db mysql.MysqlConnection, schema string, table string) (tableInfo TableInfoStruct)

type TableStruct

type TableStruct struct {
	COLUMN_NAME       *string
	COLUMN_DEFAULT    *string
	IS_NULLABLE       *string
	COLUMN_TYPE       *string
	COLUMN_KEY        *string
	EXTRA             *string
	COLUMN_COMMENT    *string
	DATA_TYPE         *string
	NUMERIC_PRECISION *uint64
	NUMERIC_SCALE     *uint64
}

func GetSchemaTableFieldList

func GetSchemaTableFieldList(db mysql.MysqlConnection, schema string, table string) []TableStruct

type ThreadStatus

type ThreadStatus struct {
	Num       int
	Error     error  // 拉取数据错误
	NowStartI uint64 // 当前执行第几条
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL