2017-10-02 08:40:33 +03:00

47 lines
655 B
Go

package canal
import (
"sync"
"github.com/ngaut/log"
"github.com/siddontang/go-mysql/mysql"
)
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
}