You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
665 B
46 lines
665 B
package canal |
|
|
|
import ( |
|
"sync" |
|
|
|
"github.com/siddontang/go-mysql/mysql" |
|
log "github.com/sirupsen/logrus" |
|
) |
|
|
|
type masterInfo struct { |
|
sync.RWMutex |
|
|
|
pos mysql.Position |
|
|
|
gtid mysql.GTIDSet |
|
} |
|
|
|
func (m *masterInfo) Update(pos mysql.Position) { |
|
log.Debugf("update master position %s", pos) |
|
|
|
m.Lock() |
|
m.pos = pos |
|
m.Unlock() |
|
} |
|
|
|
func (m *masterInfo) UpdateGTID(gtid mysql.GTIDSet) { |
|
log.Debugf("update master gtid %s", gtid.String()) |
|
|
|
m.Lock() |
|
m.gtid = gtid |
|
m.Unlock() |
|
} |
|
|
|
func (m *masterInfo) Position() mysql.Position { |
|
m.RLock() |
|
defer m.RUnlock() |
|
|
|
return m.pos |
|
} |
|
|
|
func (m *masterInfo) GTID() mysql.GTIDSet { |
|
m.RLock() |
|
defer m.RUnlock() |
|
|
|
return m.gtid |
|
}
|
|
|