1 Star 0 Fork 2

ZTQ/my2sql

forked from Yang超越/my2sql 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
hanran.liu 提交于 2021-04-24 17:34 . Add offline parsing binlog function
package main
import (
"sync"
my "my2sql/base"
"github.com/siddontang/go-mysql/replication"
)
func main() {
my.GConfCmd.IfSetStopParsPoint = false
my.GConfCmd.ParseCmdOptions()
defer my.GConfCmd.CloseFH()
if my.GConfCmd.WorkType != "stats" {
my.G_HandlingBinEventIndex = &my.BinEventHandlingIndx{EventIdx: 1, Finished: false}
}
var wg, wgGenSql sync.WaitGroup
wg.Add(1)
go my.ProcessBinEventStats(my.GConfCmd, &wg)
if my.GConfCmd.WorkType != "stats" {
wg.Add(1)
go my.PrintExtraInfoForForwardRollbackupSql(my.GConfCmd, &wg)
for i := uint(1); i <= my.GConfCmd.Threads; i++ {
wgGenSql.Add(1)
go my.GenForwardRollbackSqlFromBinEvent(i, my.GConfCmd, &wgGenSql)
}
}
if my.GConfCmd.Mode == "repl" {
my.ParserAllBinEventsFromRepl(my.GConfCmd)
} else if my.GConfCmd.Mode == "file" {
myParser := my.BinFileParser{}
myParser.Parser = replication.NewBinlogParser()
// donot parse mysql datetime/time column into go time structure, take it as string
myParser.Parser.SetParseTime(false)
// sqlbuilder not support decimal type
myParser.Parser.SetUseDecimal(false)
myParser.MyParseAllBinlogFiles(my.GConfCmd)
}
wgGenSql.Wait()
close(my.GConfCmd.SqlChan)
wg.Wait()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ztq550/my2sql.git
git@gitee.com:ztq550/my2sql.git
ztq550
my2sql
my2sql
master

搜索帮助