-
Notifications
You must be signed in to change notification settings - Fork 223
/
main.go
46 lines (39 loc) · 1.19 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"sync"
my "my2sql/base"
"github.com/go-mysql-org/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()
}