本文整理汇总了Golang中github.com/youtube/vitess/go/vt/mysqlctl/proto.ReplicationPosition.AtLeast方法的典型用法代码示例。如果您正苦于以下问题:Golang ReplicationPosition.AtLeast方法的具体用法?Golang ReplicationPosition.AtLeast怎么用?Golang ReplicationPosition.AtLeast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/mysqlctl/proto.ReplicationPosition
的用法示例。
在下文中一共展示了ReplicationPosition.AtLeast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: WaitBlpPosition
// WaitBlpPosition will wait for the filtered replication to reach at least
// the provided position.
func WaitBlpPosition(mysqld MysqlDaemon, bp *blproto.BlpPosition, waitTimeout time.Duration) error {
timeOut := time.Now().Add(waitTimeout)
for {
if time.Now().After(timeOut) {
break
}
cmd := binlogplayer.QueryBlpCheckpoint(bp.Uid)
qr, err := mysqld.FetchSuperQuery(cmd)
if err != nil {
return err
}
if len(qr.Rows) != 1 {
return fmt.Errorf("QueryBlpCheckpoint(%v) returned unexpected row count: %v", bp.Uid, len(qr.Rows))
}
var pos proto.ReplicationPosition
if !qr.Rows[0][0].IsNull() {
pos, err = proto.DecodeReplicationPosition(qr.Rows[0][0].String())
if err != nil {
return err
}
}
if pos.AtLeast(bp.Position) {
return nil
}
log.Infof("Sleeping 1 second waiting for binlog replication(%v) to catch up: %v != %v", bp.Uid, pos, bp.Position)
time.Sleep(1 * time.Second)
}
return fmt.Errorf("WaitBlpPosition(%v) timed out", bp.Uid)
}